diff --git a/public_html/css/container.css b/public_html/css/container.css index 863243b..95d541e 100644 --- a/public_html/css/container.css +++ b/public_html/css/container.css @@ -68,7 +68,8 @@ font-size: .8em; } - #CONTAINER.message div span.del{ /* Del btn */ + #CONTAINER.message div span.del, /* Del btn */ + #CONTAINER.message div span.upd{ /* Update btn */ display: block; position: absolute; top: calc( 100% + .2em ); @@ -82,10 +83,19 @@ cursor: pointer; } + #CONTAINER.message div span.upd{ + left: calc( 100% - 3em ); + background-image: url('/image/container/edit-msg.svg@777777'); + } + #CONTAINER.message div span.del:hover{ background-image: url('/image/container/del-msg.svg@e33222') } + #CONTAINER.message div span.upd:hover{ + background-image: url('/image/container/edit-msg.svg@2ab1dd') + } + #CONTAINER.message div span span.code{ /* Code block */ display: inline-block; position: relative; diff --git a/public_html/image/container/edit-msg.svg b/public_html/image/container/edit-msg.svg new file mode 100644 index 0000000..14be2ad --- /dev/null +++ b/public_html/image/container/edit-msg.svg @@ -0,0 +1,59 @@ + + diff --git a/view/vue-config.js b/view/vue-config.js index b4c4325..36e46c3 100644 --- a/view/vue-config.js +++ b/view/vue-config.js @@ -129,6 +129,12 @@ gstore.add('new_msg', { emergency: '', event: '' }); +// edit-message container +gstore.add('upd_msg', { + inbox: null, + emergency: null, + event: null +}); // if message loader gstore.add('msg_pending', { inbox: true, diff --git a/view/vue/container/emergency.vue b/view/vue/container/emergency.vue index 99deb50..4d422b4 100644 --- a/view/vue/container/emergency.vue +++ b/view/vue/container/emergency.vue @@ -7,6 +7,7 @@ +
@@ -53,31 +54,86 @@ export default { if( msg.trim().length == 0 ) return; - /* (2) Prepare request */ - var rq = { - message: this.gstore.new_msg.emergency, - location: this.gstore.loc, - username: this.gstore.server.session.name - }; - /* (3) Add loader */ - gstore.data.msg_pending.emergency = true; - /* (4) Send request */ - api.call("POST message/emergency/"+this.dep, rq, function(rs){ + /* (1) If in EDIT_MODE + ---------------------------------------------------------*/ + if( gstore.data.upd_msg.emergency != null ){ - // {1} If error -> exit // - if( rs.error != 0 ) - return; + /* (2) Prepare request */ + var rq = { + id: this.gstore.upd_msg.emergency, + message: msg + }; - // {2} Empty input // - gstore.data.new_msg.emergency = ''; + /* (3) Add loader */ + gstore.data.msg_pending.emergency = true; + + /* (4) Send request */ + api.call("PUT message/emergency/"+this.dep, rq, function(rs){ + + // {1} If error -> exit // + if( rs.error != 0 ) + return; + + // {2} Update message content // + for( var id in gstore.data.notif.emergency.data ) + if( gstore.data.notif.emergency.data[id].id == gstore.data.upd_msg.emergency ) + gstore.data.notif.emergency.data[id].message = msg; + + + // {3} exit EDIT_MODE // + gstore.data.upd_msg.emergency = null; + + // {4} Empty input // + gstore.data.new_msg.emergency = ''; + + }); + + + + /* (2) If IN NEW_MSG_MODE + ---------------------------------------------------------*/ + }else{ + + /* (2) Prepare request */ + var rq = { + message: this.gstore.new_msg.emergency, + location: this.gstore.loc, + username: this.gstore.server.session.name + }; + + /* (3) Add loader */ + gstore.data.msg_pending.emergency = true; + + /* (4) Send request */ + api.call("POST message/emergency/"+this.dep, rq, function(rs){ + + // {1} If error -> exit // + if( rs.error != 0 ) + return; + + // {2} Empty input // + gstore.data.new_msg.emergency = ''; + + }); + + } - }); }, del_message(id_msg){ api.call("DELETE message/emergency/"+this.dep, { id: id_msg }, function(rs){}); + }, + upd_message(id_msg, msg_content){ + + /* (1) Move to 'edit_mode' */ + this.gstore.upd_msg.emergency = id_msg; + + /* (2) Copy message content to INPUT */ + this.gstore.new_msg.emergency = msg_content; + + }, bbcode: function(msg){ return this.gstore.func.bbcode(msg);