feat(submit): fold slide cover into multi-select image picker
Match the featured cover buttons row to the reference theme: drop the dedicated slide button, let the icon-only image picker select multiple images into a slide cover (single pick stays an image cover), and align the loaded-state visibility matrix.
This commit is contained in:
+22
-18
@@ -88,6 +88,7 @@
|
||||
isDirty: false,
|
||||
isSubmitting: false,
|
||||
featured: { type: '', data: {} },
|
||||
featuredOptions: {},
|
||||
|
||||
init: function () {
|
||||
this.form = document.getElementById('aksrt-submit-form');
|
||||
@@ -387,6 +388,7 @@
|
||||
if (args && args.type) {
|
||||
this.featured = { type: args.type, data: args.data || {} };
|
||||
}
|
||||
this.featuredOptions = (args && args.options) || {};
|
||||
} catch (e) {}
|
||||
},
|
||||
|
||||
@@ -487,28 +489,30 @@
|
||||
return;
|
||||
}
|
||||
if (act === 'image') {
|
||||
// 与服务端 featured 校验对齐:多选(或仅有幻灯片权限时的单选)存为幻灯片封面,其余存为图片封面。
|
||||
var coverOptions = self.featuredOptions || {};
|
||||
var slideEnabled = !!coverOptions.slide;
|
||||
var imageAllowed = !!coverOptions.image;
|
||||
self.openMediaPicker({
|
||||
type: 'image',
|
||||
multiple: false,
|
||||
allowExternal: false,
|
||||
onSelect: function (item) {
|
||||
if (!item) return;
|
||||
self.setFeatured('image', { url: item.url || '', id: item.attachment_id || item.id || 0 });
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (act === 'slide') {
|
||||
self.openMediaPicker({
|
||||
type: 'image',
|
||||
multiple: true,
|
||||
maxItems: 30,
|
||||
multiple: slideEnabled,
|
||||
maxItems: slideEnabled ? 30 : 1,
|
||||
allowExternal: false,
|
||||
onSelect: function (items) {
|
||||
var slides = (Array.isArray(items) ? items : []).map(function (item) {
|
||||
return { url: item.url || '', id: item.attachment_id || item.id || 0 };
|
||||
}).filter(function (item) { return item.url || item.id; });
|
||||
if (slides.length) self.setFeatured('slide', slides);
|
||||
var list = Array.isArray(items) ? items : [items];
|
||||
var slides = [];
|
||||
list.forEach(function (item) {
|
||||
if (!item) return;
|
||||
var url = item.url || '';
|
||||
var id = item.attachment_id || item.id || 0;
|
||||
if (url || id) slides.push({ url: url, id: id });
|
||||
});
|
||||
if (!slides.length) return;
|
||||
if (slides.length > 1 || (slideEnabled && !imageAllowed)) {
|
||||
self.setFeatured('slide', slides);
|
||||
return;
|
||||
}
|
||||
self.setFeatured('image', slides[0]);
|
||||
},
|
||||
});
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user