ADDED update client (js)

This commit is contained in:
xdrm-brackets 2017-12-08 05:04:49 +01:00
parent 1463253b86
commit 5a8cc4ddb7
4 changed files with 148 additions and 17 deletions

View File

@ -68,7 +68,8 @@
font-size: .8em; 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; display: block;
position: absolute; position: absolute;
top: calc( 100% + .2em ); top: calc( 100% + .2em );
@ -82,10 +83,19 @@
cursor: pointer; 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{ #CONTAINER.message div span.del:hover{
background-image: url('/image/container/del-msg.svg@e33222') 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 */ #CONTAINER.message div span span.code{ /* Code block */
display: inline-block; display: inline-block;
position: relative; position: relative;

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="35.994999"
viewBox="0 0 35.994999 35.994999"
width="35.994999"
id="svg4173"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="edit-msg.svg">
<metadata
id="metadata4183">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs4181" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1056"
id="namedview4179"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="19.833333"
inkscape:cx="18"
inkscape:cy="18"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:current-layer="svg4173" />
<path
d="m 29.324219,0 c -0.5125,0 -1.024063,0.1959375 -1.414063,0.5859375 L 24.25,4.2441406 l 7.5,7.5000004 3.660156,-3.6582035 c 0.78,-0.78 0.78,-2.0500781 0,-2.8300781 L 30.740234,0.5859375 C 30.350234,0.1959375 29.836719,0 29.324219,0 Z M 22.130859,6.3652344 0,28.494141 l 0,7.5 7.5,0 22.130859,-22.128907 -7.5,-7.4999996 z"
id="fill-edit"
inkscape:connector-curvature="0" />
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -129,6 +129,12 @@ gstore.add('new_msg', {
emergency: '', emergency: '',
event: '' event: ''
}); });
// edit-message container
gstore.add('upd_msg', {
inbox: null,
emergency: null,
event: null
});
// if message loader // if message loader
gstore.add('msg_pending', { gstore.add('msg_pending', {
inbox: true, inbox: true,

View File

@ -7,6 +7,7 @@
<span class='content' v-html='bbcode(msg.message)'></span> <span class='content' v-html='bbcode(msg.message)'></span>
<span class='date' v-text='local_date(id)'></span> <span class='date' v-text='local_date(id)'></span>
<span @click='del_message(msg.id)' class='del' v-if='msg.user == gstore.server.session.name'></span> <span @click='del_message(msg.id)' class='del' v-if='msg.user == gstore.server.session.name'></span>
<span @click='upd_message(msg.id, msg.message)' class='upd' v-if='msg.user == gstore.server.session.name'></span>
</div> </div>
<div class='end-pad'></div> <!-- End Spacing --> <div class='end-pad'></div> <!-- End Spacing -->
@ -53,31 +54,86 @@ export default {
if( msg.trim().length == 0 ) if( msg.trim().length == 0 )
return; 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 */ /* (1) If in EDIT_MODE
api.call("POST message/emergency/"+this.dep, rq, function(rs){ ---------------------------------------------------------*/
if( gstore.data.upd_msg.emergency != null ){
// {1} If error -> exit // /* (2) Prepare request */
if( rs.error != 0 ) var rq = {
return; id: this.gstore.upd_msg.emergency,
message: msg
};
// {2} Empty input // /* (3) Add loader */
gstore.data.new_msg.emergency = ''; 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){ del_message(id_msg){
api.call("DELETE message/emergency/"+this.dep, { id: id_msg }, function(rs){}); 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){ bbcode: function(msg){
return this.gstore.func.bbcode(msg); return this.gstore.func.bbcode(msg);