From e7ffcfc152e590dc83a98617e0e3593a27de29e3 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 22 Mar 2018 19:13:52 +0100 Subject: [PATCH] [lib.popup-controller] added [lib.room-controller] create() method [vue.wrapper] popup now works --- public_html/index.html | 2 +- webpack/common.js | 10 +++++++--- webpack/lib/popup-controller.js | 20 ++++++++++++++++++++ webpack/lib/room-controller.js | 29 +++++++++++++++++++++++++++++ webpack/vue/dialog.vue | 2 +- webpack/vue/wrapper.vue | 18 ++++++++---------- 6 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 webpack/lib/popup-controller.js diff --git a/public_html/index.html b/public_html/index.html index c47c030..b1d1499 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -18,7 +18,7 @@ - + diff --git a/webpack/common.js b/webpack/common.js index 44908ee..ccbc236 100644 --- a/webpack/common.js +++ b/webpack/common.js @@ -1,6 +1,7 @@ import {GlobalStore} from './lib/gstore' import VueRouter from 'vue-router' import routes from './routes' +import {PopupController} from './lib/popup-controller' import {ContentController} from './lib/content-controller' import {RoomController} from './lib/room-controller' import {ChannelController} from './lib/channel-controller' @@ -26,11 +27,14 @@ gs.set('router', new VueRouter({ /* (2) Main components ---------------------------------------------------------*/ -/* (1) Initialize content management */ +/* (1) Initialize popup management */ +gs.set('popup', new PopupController()); + +/* (2) Initialize content management */ gs.set('content', new ContentController()); -/* (2) Initialize rooms & room menu */ +/* (3) Initialize rooms & room menu */ gs.set('room', new RoomController()); -/* (3) Initialize channels & channel menu */ +/* (4) Initialize channels & channel menu */ gs.set('channel', new ChannelController()); \ No newline at end of file diff --git a/webpack/lib/popup-controller.js b/webpack/lib/popup-controller.js new file mode 100644 index 0000000..6775baf --- /dev/null +++ b/webpack/lib/popup-controller.js @@ -0,0 +1,20 @@ +export class PopupController{ + + /* (1) Construct default attributes + * + ---------------------------------------------------------*/ + constructor(){ + + /* (1) Popups */ + this.croom = { + active: false, + type: 'text', + name: '', + reset(){ this.active = false; this.type = 'text'; this.name = ''; }, + submit(){ gs.get.room.create(this.type, this.name) && this.reset(); } + } + + + } + +} \ No newline at end of file diff --git a/webpack/lib/room-controller.js b/webpack/lib/room-controller.js index 8f53a21..6da4dbf 100644 --- a/webpack/lib/room-controller.js +++ b/webpack/lib/room-controller.js @@ -147,5 +147,34 @@ export class RoomController{ } + /* (5) Create a new room + * + * @type room type + * @name room name + * + * @return created Whether the room has been created + * + ---------------------------------------------------------*/ + create(type=null, name=null){ + + /* (1) Manage invalid @type */ + if( typeof type !== 'string' || this[type] == null ) + return false; + + /* (2) Manage invalid @name */ + if( typeof name !== 'string' ) + return false; + + /* (3) Try to create room in API */ + console.log(`POST /channel/${gs.get.content.cid}/room/${type}`); + + /* (4) Add room -> update VueJS */ + + + return true; + + } + + } \ No newline at end of file diff --git a/webpack/vue/dialog.vue b/webpack/vue/dialog.vue index df2a55f..75b36af 100644 --- a/webpack/vue/dialog.vue +++ b/webpack/vue/dialog.vue @@ -17,7 +17,7 @@ @click='rooms.visible=!rooms.visible'> {{ type }} rooms -
+
  • -