frontendeditor 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53a48204e48bea0144ff067375495132baf90899
4
- data.tar.gz: 49c3eaeccf695e0a9968262bd235e7775f6d019e
3
+ metadata.gz: a5446052de1900294655723753c99e6ece09468e
4
+ data.tar.gz: c5f81ef54d549d7c4eb8d67b9bf00e0c428700e6
5
5
  SHA512:
6
- metadata.gz: 24b6de36c120934d7c6358fc4e1620e46b3ae8761aae0b9cd9197064b7fce12f5c4446c80870265a0ba81a74cd916d4d5a788593f54720f3957b104b1adbeb90
7
- data.tar.gz: 11b6b74731fa47a6d107f8fbfd1df94f2cc78bc08caab2a1706550cdcb40ef16612955796f22d39643a17ba2b3f0fd4ca7c712d2494c7105b27c01f152896a8b
6
+ metadata.gz: 300b1c21b7cfb4c6e71090c9b461dfc2cfade9892c0ad9ead91752487e313f9f2dd6f1fafb95c565d46e08e0038abd80d6ff70443e692b192218461b0b8ab39d
7
+ data.tar.gz: 8d754ae6054629f095ce75a7d215baf37f3b3bdbae73089534aa9e62a56eb6e2ea3187d10eec9bc308ee8ca229497a6db90159492b03fd029b7689358e58c268
@@ -1,3 +1,3 @@
1
1
  module Frontendeditor
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -12,10 +12,19 @@
12
12
  };
13
13
 
14
14
  Editor.commitAll = function() {
15
- var model;
16
- model = FrontendEditor.getCurrentModel('pages');
17
- model.set('id', this.el().data('id'));
18
- return model.set(this.el().data('attribute'), this.el().find('textarea').html());
15
+ var attributes, model, objectName, values;
16
+ objectName = this.el().data('object');
17
+ model = FrontendEditor.findCurrentOrCreateModel(objectName);
18
+ values = {
19
+ id: this.el().data('id')
20
+ };
21
+ values[this.el().data('attribute')] = this.el().find('textarea').html();
22
+ attributes = {
23
+ values: values,
24
+ prefix: this.el().data('prefix'),
25
+ objectName: objectName
26
+ };
27
+ return model.setAttributes(attributes);
19
28
  };
20
29
 
21
30
  Editor.deactive = function() {
@@ -15,11 +15,11 @@
15
15
  $('body').prepend(view.render().el);
16
16
  return this.currentModels = new FrontendEditor.Collections.InlineEditor.Items();
17
17
  },
18
- getCurrentModel: function(modelName) {
18
+ findCurrentOrCreateModel: function(modelName) {
19
19
  var currentModel;
20
20
  currentModel = this.currentModels[modelName];
21
21
  if (currentModel === void 0) {
22
- currentModel = new this.Models.Item(modelName);
22
+ currentModel = new this.Models.Item();
23
23
  this.currentModels.add(currentModel);
24
24
  }
25
25
  return currentModel;
@@ -33,12 +33,27 @@
33
33
  return Item.__super__.constructor.apply(this, arguments);
34
34
  }
35
35
 
36
- Item.prototype.initialize = function(plural) {
37
- return this.urlRoot = "/" + plural;
36
+ Item.prototype.setAttributes = function(attributes) {
37
+ this.setUrlRoot(attributes);
38
+ return this.setValues(attributes.values);
38
39
  };
39
40
 
40
- Item.prototype.prefix = function(prefix) {
41
- return this.urlRoot = prefix + this.urlRoot;
41
+ Item.prototype.setValues = function(values) {
42
+ var key, value, _results;
43
+ _results = [];
44
+ for (key in values) {
45
+ value = values[key];
46
+ _results.push(this.set(key, value));
47
+ }
48
+ return _results;
49
+ };
50
+
51
+ Item.prototype.setUrlRoot = function(attributes) {
52
+ if (attributes.prefix) {
53
+ return this.urlRoot = "" + attributes.prefix + "/" + attributes.objectName;
54
+ } else {
55
+ return this.urlRoot = "/" + attributes.objectName;
56
+ }
42
57
  };
43
58
 
44
59
  return Item;
@@ -71,12 +86,7 @@
71
86
  };
72
87
 
73
88
  ToolbarView.prototype.saveChanges = function(event) {
74
- var prefix;
75
89
  Editor.commitAll();
76
- prefix = Editor.el().data('prefix');
77
- if (prefix) {
78
- FrontendEditor.currentModels.prefix(prefix);
79
- }
80
90
  FrontendEditor.currentModels.save();
81
91
  FrontendEditor.currentModels.reset();
82
92
  alert("Enregistrement Effectué");
@@ -120,12 +130,6 @@
120
130
  });
121
131
  };
122
132
 
123
- Items.prototype.prefix = function(prefix) {
124
- return this.each(function(model) {
125
- return model.prefix(prefix);
126
- });
127
- };
128
-
129
133
  return Items;
130
134
 
131
135
  })(Backbone.Collection);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frontendeditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - gcorbel