-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
84 lines (70 loc) · 1.97 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var _ = require('lodash');
module.exports = {
moogBundle: {
modules: ['apostrophe-svg-sprites-widgets'],
directory: 'lib/modules'
},
name: 'apostrophe-svg-sprites',
extend: 'apostrophe-pieces',
alias: 'svg-sprites',
label: 'SVG Sprite',
pluralLabel: 'SVG Sprites',
perPage: 20,
manageViews: ['grid', 'list'],
searchable: false,
insertViaUpload: false,
beforeConstruct: function (self, options) {
var mapChoices = _.map(options.maps, function (map) {
return { label: map.label, value: map.name };
});
options.addFields = [
{
name: 'id',
label: 'ID',
type: 'string',
help: 'ID of the <symbol> element in the map',
required: true
},
{
name: 'map',
label: 'Map',
type: 'select',
choices: mapChoices,
required: true,
readOnly: true
}
].concat(options.addFields || []);
var mainFieldNames = _.map(options.addFields, function (field) {
return field.name;
});
mainFieldNames.unshift('title');
options.arrangeFields = [
{
name: 'main',
label: 'Main Fields',
fields: mainFieldNames
},
{
name: 'admin',
label: 'Admin',
fields: ['slug', 'published', 'tags']
}
].concat(options.arrangeFields || []);
},
construct: function (self, options) {
self.pushAsset('stylesheet', 'apos-sprites', { when: 'user' });
self.pushAsset('script', 'editor-modal', { when: 'user' });
require('./lib/import.js')(self, options);
var superGetListProjection = self.getListProjection;
self.getListProjection = function(req) {
var projection = superGetListProjection(req);
projection.file = 1;
projection.id = 1;
projection.map = 1;
return projection;
};
},
afterConstruct: function (self) {
self.apos.tasks.add(self.__meta.name, 'import', 'Imports sprites from provided SVG maps as pieces', self.import);
}
};