Commit 063b6602dc8e49a0e2e05826dd1e2c0a5c09b92e
Fix map plugin save throwing error
Map plugin was throwing error while saving, this was because it was assumed
that all types would have atleast an attribute called data. Fix that.
| | | | 162 | }, | 162 | }, |
---|
163 | listContent: function() { | 163 | listContent: function() { |
---|
164 | var content = ''; | 164 | var content = ''; |
---|
| | 165 | var base_props = _.keys(new M.types.model.base().defaults); |
---|
165 | _.each(this.model.get('content'), function(element, idx) { | 166 | _.each(this.model.get('content'), function(element, idx) { |
---|
| | 167 | //prepare the more field |
---|
| | 168 | var moar = ''; |
---|
| | 169 | _.each(element, function(v, k) { |
---|
| | 170 | //check if not one of the base properties..add it to more.. |
---|
| | 171 | if(_.indexOf(base_props, k) < 0) { |
---|
| | 172 | moar += (v) ? v + ', ' : ''; |
---|
| | 173 | } |
---|
| | 174 | }); |
---|
166 | content += this.contentListTemplate({ | 175 | content += this.contentListTemplate({ |
---|
167 | no: idx, | 176 | no: idx, |
---|
168 | type: element.type, | 177 | type: element.type, |
---|
169 | more: element.src || | | more: element.src || |
---|
170 | escapeHtml(element.data.substring(0, 30) + '..'), | | escapeHtml(element.data.substring(0, 30) + '..'), |
---|
| | 178 | more: escapeHtml(moar.substring(0, 30) + '..'), | 171 | title: (element.title) ? element.title + ',' : '' | 179 | title: (element.title) ? element.title + ',' : '' |
---|
172 | }); | 180 | }); |
---|
173 | }, this); | 181 | }, this); |
---|
… | | … | |
---|
394 | new_attrs[prop] = val; | 394 | new_attrs[prop] = val; |
---|
395 | }); | 395 | }); |
---|
396 | new_attrs['type'] = this.$select.val(); | 396 | new_attrs['type'] = this.$select.val(); |
---|
397 | if(this.wysiwyg) { | | if(this.wysiwyg) { |
---|
398 | var data = M.editor.wysiwyg.save('#edit'); | | var data = M.editor.wysiwyg.save('#edit'); |
---|
399 | new_attrs['data'] = data; | | new_attrs['data'] = data; |
---|
400 | } | | } |
---|
401 | else { | | else { |
---|
402 | var data = M.editor.code.save('code-edit'); | | var data = M.editor.code.save('code-edit'); |
---|
403 | new_attrs['data'] = data; | | new_attrs['data'] = data; |
---|
| | 397 | if(this.$select.val() === 'text') { | | | 398 | if(this.wysiwyg) { |
---|
| | 399 | var data = M.editor.wysiwyg.save('#edit'); |
---|
| | 400 | new_attrs['data'] = data; |
---|
| | 401 | } |
---|
| | 402 | else { |
---|
| | 403 | var data = M.editor.code.save('code-edit'); |
---|
| | 404 | new_attrs['data'] = data; |
---|
| | 405 | } |
---|
404 | } | 406 | } |
---|
405 | this.model.set(new_attrs); | 407 | this.model.set(new_attrs); |
---|
406 | M.editor.pageview.updateContent(this.model.toJSON()); | 408 | M.editor.pageview.updateContent(this.model.toJSON()); |
---|
| | | | 4 | defaults: { | 4 | defaults: { |
---|
5 | tags: [], | 5 | tags: [], |
---|
6 | title: "", | 6 | title: "", |
---|
7 | attr: {} | | attr: {} |
---|
| | 7 | attr: {}, | | | 8 | type: '' |
---|
8 | }, | 9 | }, |
---|
9 | initialize: function() { | 10 | initialize: function() { |
---|
10 | } | 11 | } |
---|
… | | … | |
---|
62 | // Map model | 62 | // Map model |
---|
63 | var Map = BaseType.extend({ | 63 | var Map = BaseType.extend({ |
---|
64 | defaults: _.extend({ | 64 | defaults: _.extend({ |
---|
65 | tileLayer:"", | | tileLayer:"", |
---|
| | 65 | tileLayer: "", | 66 | shp: "" | 66 | shp: "" |
---|
67 | }, BaseType.prototype.defaults), | 67 | }, BaseType.prototype.defaults), |
---|
68 | initialize: function(){ | 68 | initialize: function(){ |
---|
… | | … | |
---|
139 | //export types to the typemap | 139 | //export types to the typemap |
---|
140 | M.types = M.types || {}; | 140 | M.types = M.types || {}; |
---|
141 | M.types.model = { | 141 | M.types.model = { |
---|
| | 142 | 'base': BaseType, |
---|
142 | 'text': Text, | 143 | 'text': Text, |
---|
143 | 'image': Image, | 144 | 'image': Image, |
---|
144 | 'video': Video, | 145 | 'video': Video, |
---|