From 9b18d3083d2b33df3cb1ddbe3308d07ce08f3094 Mon Sep 17 00:00:00 2001 From: hylom Date: Thu, 7 Jun 2018 21:22:04 +0900 Subject: [PATCH] implement AD code manager (working) --- src/newslash_web/public/js/ad-codes-editor.js | 39 ++++++++++------------ .../templates/admin/ads/index.html.tt2 | 17 +++++++--- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/newslash_web/public/js/ad-codes-editor.js b/src/newslash_web/public/js/ad-codes-editor.js index 8f6c5598..58040a62 100644 --- a/src/newslash_web/public/js/ad-codes-editor.js +++ b/src/newslash_web/public/js/ad-codes-editor.js @@ -5,7 +5,8 @@ var vm; editor.run = function run (params) { const data = { message: '', - boxItems: [], + adCodes: [], + selected: {}, }; const computed = {}; const methods = { @@ -44,28 +45,22 @@ editor.run = function run (params) { }); } }, - newItem: function newItem() { + addItem: function addItem() { const item = { - id: 0, + ad_id: 0, name: 'new item', - comment: '', - model: '', - query_params: '', - limit: '', - template: '', - selected: false, - editing: true, - edited: true, + description: '', + enabled: true, + status: 'enabled', + content: '', }; - const it = this.boxItems.push(item); + const it = this.adCodes.push(item); }, }; function initItems (items) { items.forEach(item => { - Vue.set(item, 'selected', false); - Vue.set(item, 'editing', false); - Vue.set(item, 'edited', false); + Vue.set(item, 'enabled', item.status == "enabled"); }); }; @@ -73,18 +68,20 @@ editor.run = function run (params) { data: data, computed: computed, methods: methods, - created: function () { - newslash.admin.getBoxes().then( + + created: function onCreate() { + newslash.admin.getADCodes().then( (resp) => { // success - this.boxItems = resp.items || []; + this.adCodes = resp.items || []; this.message = resp.message || ''; - initItems(this.boxItems); + initItems(this.adCodes); }, (resp) => { // fail - this.boxItems = []; - this.message = resp.message || "failed to get items"; + this.adCodes = []; + this.message = resp.message || "failed to get AD codes"; } ); + }, }); }; diff --git a/src/newslash_web/templates/admin/ads/index.html.tt2 b/src/newslash_web/templates/admin/ads/index.html.tt2 index dd0ef153..1e6c3745 100644 --- a/src/newslash_web/templates/admin/ads/index.html.tt2 +++ b/src/newslash_web/templates/admin/ads/index.html.tt2 @@ -7,15 +7,24 @@
- + +
- +
- + +
+
+ +
+
+