Browse Source

Ajout possibilité d'éditer le jeton du slot

develop
William Petit 2 years ago
parent
commit
5c6701007c
1 changed files with 20 additions and 2 deletions
  1. 20
    2
      client/js/app.js

+ 20
- 2
client/js/app.js View File

@@ -183,6 +183,7 @@
183 183
 
184 184
     view: function(ctrl, attrs) {
185 185
       var slot = attrs.slot;
186
+      var tokenEditable = attrs.tokenEditable;
186 187
       return m('form.form', [
187 188
         m('.form-group', [
188 189
           m('label[for="slotLabelInput"]', 'Label'),
@@ -193,7 +194,22 @@
193 194
         ]),
194 195
         m('.form-group', [
195 196
           m('label[for="slotTokenInput"]', 'Token'),
196
-          m('input.form-control[id="slotTokenInput"][readonly][required]', {value: slot.token()})
197
+          m('div.input-group', [
198
+            m('input.form-control[id="slotTokenInput"][required]', (function() {
199
+              var attrs = {
200
+                value: slot.token(),
201
+                onchange: m.withAttr('value', slot.token)
202
+              };
203
+              if(!tokenEditable()) attrs.readonly = true;
204
+              return attrs;
205
+            }())),
206
+            m('div.input-group-btn', [
207
+              m('button.btn.btn-default', { onclick: function() { tokenEditable(!tokenEditable()); } }, [
208
+                'Edit ',
209
+                m('i.glyphicon.glyphicon-pencil')
210
+              ])
211
+            ])
212
+          ])
197 213
         ]),
198 214
         m('.form-group', [
199 215
           m('label[for="slotHandlerInput"]', 'Handler'),
@@ -399,6 +415,7 @@
399 415
       var slotModalState = this.slotModalState = m.prop('hide');
400 416
       var slotModalTitle = this.slotModalTitle = m.prop('Add slot');
401 417
       var editedSlot = this.editedSlot = m.prop(new Marang.Models.Slot());
418
+      var tokenEditable = this.tokenEditable = m.prop(false);
402 419
 
403 420
       Marang.Models.loadServerInfo();
404 421
       Marang.Models.loadSlots();
@@ -421,6 +438,7 @@
421 438
       };
422 439
 
423 440
       this.editSlot = function(slot) {
441
+        tokenEditable(false);
424 442
         editedSlot(slot);
425 443
         slotModalTitle('Edit slot');
426 444
         slotModalState('show');
@@ -468,7 +486,7 @@
468 486
         m(Marang.Components.Modal, {
469 487
           state: ctrl.slotModalState(),
470 488
           title: ctrl.slotModalTitle(),
471
-          content: m(Marang.Components.SlotForm, {slot: ctrl.editedSlot()}),
489
+          content: m(Marang.Components.SlotForm, { slot: ctrl.editedSlot(), tokenEditable: ctrl.tokenEditable }),
472 490
           onSuccess: ctrl.saveSlot,
473 491
           onClose: ctrl.onModalClose
474 492
         }),

Loading…
Cancel
Save