Signature refactoring.

This commit is contained in:
Julia Radzhabova 2017-11-21 11:34:38 +03:00
parent c5479c0052
commit ae40346e26
7 changed files with 240 additions and 167 deletions

View file

@ -323,8 +323,8 @@ define([
var date = certificate.date, var date = certificate.date,
arr_date = (typeof date == 'string') ? date.split(' - ') : ['', '']; arr_date = (typeof date == 'string') ? date.split(' - ') : ['', ''];
this.cntCertificate.html(this.templateCertificate({name: certificate.name, valid: this.textValid.replace('%1', arr_date[0]).replace('%2', arr_date[1])})); this.cntCertificate.html(this.templateCertificate({name: certificate.name, valid: this.textValid.replace('%1', arr_date[0]).replace('%2', arr_date[1])}));
this.cntCertificate.toggleClass('hidden', this.certificateId<0); this.cntCertificate.toggleClass('hidden', _.isEmpty(this.certificateId) || this.certificateId<0);
this.btnOk.setDisabled(this.certificateId<0); this.btnOk.setDisabled(_.isEmpty(this.certificateId) || this.certificateId<0);
}, },
onSelectImage: function() { onSelectImage: function() {

View file

@ -63,11 +63,12 @@ define([
initialize: function () { initialize: function () {
this._state = { this._state = {
requestedSignatures: undefined,
validSignatures: undefined,
invalidSignatures: undefined,
DisabledEditing: false, DisabledEditing: false,
ready: false ready: false,
hasValid: false,
hasInvalid: false,
hasRequested: false,
tip: undefined
}; };
this._locked = false; this._locked = false;
@ -88,7 +89,7 @@ define([
enableKeyEvents: false, enableKeyEvents: false,
itemTemplate: _.template([ itemTemplate: _.template([
'<div id="<%= id %>" class="signature-item requested">', '<div id="<%= id %>" class="signature-item requested">',
'<div class="caret img-commonctrl"></div>', '<div class="caret img-commonctrl nomargin"></div>',
'<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>', '<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>',
'</div>' '</div>'
].join('')) ].join(''))
@ -99,7 +100,7 @@ define([
enableKeyEvents: false, enableKeyEvents: false,
itemTemplate: _.template([ itemTemplate: _.template([
'<div id="<%= id %>" class="signature-item">', '<div id="<%= id %>" class="signature-item">',
'<div class="caret img-commonctrl"></div>', '<div class="caret img-commonctrl <% if (name == "" || date == "") { %>' + 'nomargin' + '<% } %>"></div>',
'<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>', '<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>',
'<div class="date"><%= Common.Utils.String.htmlEncode(date) %></div>', '<div class="date"><%= Common.Utils.String.htmlEncode(date) %></div>',
'</div>' '</div>'
@ -111,7 +112,7 @@ define([
enableKeyEvents: false, enableKeyEvents: false,
itemTemplate: _.template([ itemTemplate: _.template([
'<div id="<%= id %>" class="signature-item">', '<div id="<%= id %>" class="signature-item">',
'<div class="caret img-commonctrl"></div>', '<div class="caret img-commonctrl <% if (name == "" || date == "") { %>' + 'nomargin' + '<% } %>"></div>',
'<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>', '<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>',
'<div class="date"><%= Common.Utils.String.htmlEncode(date) %></div>', '<div class="date"><%= Common.Utils.String.htmlEncode(date) %></div>',
'</div>' '</div>'
@ -144,7 +145,7 @@ define([
}, },
ChangeSettings: function(props) { ChangeSettings: function(props) {
if (!this._state.requestedSignatures || !this._state.validSignatures || !this._state.invalidSignatures) if (!this._state.hasRequested && !this._state.hasValid && !this._state.hasInvalid)
this.updateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures()); this.updateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures());
}, },
@ -160,36 +161,41 @@ define([
if (!this._state.ready) return; if (!this._state.ready) return;
this.updateSignatures(valid, requested); this.updateSignatures(valid, requested);
this.showSignatureTooltip(this._state.validSignatures.length>0, this._state.invalidSignatures.length>0); this.showSignatureTooltip(this._state.hasValid, this._state.hasInvalid);
}, },
updateSignatures: function(valid, requested){ updateSignatures: function(valid, requested){
var me = this; var me = this,
me._state.requestedSignatures = []; requestedSignatures = [],
me._state.validSignatures = []; validSignatures = [],
me._state.invalidSignatures = []; invalidSignatures = [];
_.each(requested, function(item, index){ _.each(requested, function(item, index){
me._state.requestedSignatures.push({name: item.asc_getSigner1(), guid: item.asc_getGuid(), requested: true}); requestedSignatures.push({name: item.asc_getSigner1(), guid: item.asc_getGuid(), requested: true});
}); });
_.each(valid, function(item, index){ _.each(valid, function(item, index){
var sign = {name: item.asc_getSigner1(), certificateId: item.asc_getId(), guid: item.asc_getGuid(), date: item.asc_getDate(), invisible: !item.asc_getVisible()}; var item_date = item.asc_getDate();
(item.asc_getValid()==0) ? me._state.validSignatures.push(sign) : me._state.invalidSignatures.push(sign); var sign = {name: item.asc_getSigner1(), certificateId: item.asc_getId(), guid: item.asc_getGuid(), date: (!_.isEmpty(item_date)) ? new Date(item_date).toLocaleString() : '', invisible: !item.asc_getVisible()};
(item.asc_getValid()==0) ? validSignatures.push(sign) : invalidSignatures.push(sign);
}); });
// me._state.requestedSignatures = [{name: 'Hammish Mitchell', guid: '123', requested: true}, {name: 'Someone Somewhere', guid: '123', requested: true}, {name: 'Mary White', guid: '123', requested: true}, {name: 'John Black', guid: '123', requested: true}]; // requestedSignatures = [{name: 'Hammish Mitchell', guid: '123', requested: true}, {name: 'Someone Somewhere', guid: '123', requested: true}, {name: 'Mary White', guid: '123', requested: true}, {name: 'John Black', guid: '123', requested: true}];
// me._state.validSignatures = [{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017', invisible: true}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}]; // validSignatures = [{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017', invisible: true}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}];
// me._state.invalidSignatures = [{name: 'Mary White', guid: '111', date: '18/05/2017'}, {name: 'John Black', guid: '456', date: '18/05/2017'}]; // invalidSignatures = [{name: 'Mary White', guid: '111', date: '18/05/2017'}, {name: 'John Black', guid: '456', date: '18/05/2017'}];
this.viewRequestedList.store.reset(me._state.requestedSignatures); me._state.hasValid = validSignatures.length>0;
this.viewValidList.store.reset(me._state.validSignatures); me._state.hasInvalid = invalidSignatures.length>0;
this.viewInvalidList.store.reset(me._state.invalidSignatures); me._state.hasRequested = requestedSignatures.length>0;
this.$el.find('.requested').toggleClass('hidden', me._state.requestedSignatures.length<1); this.viewRequestedList.store.reset(requestedSignatures);
this.$el.find('.valid').toggleClass('hidden', me._state.validSignatures.length<1); this.viewValidList.store.reset(validSignatures);
this.$el.find('.invalid').toggleClass('hidden', me._state.invalidSignatures.length<1); this.viewInvalidList.store.reset(invalidSignatures);
me.disableEditing(me._state.validSignatures.length>0 || me._state.invalidSignatures.length>0); this.$el.find('.requested').toggleClass('hidden', !me._state.hasRequested);
this.$el.find('.valid').toggleClass('hidden', !me._state.hasValid);
this.$el.find('.invalid').toggleClass('hidden', !me._state.hasInvalid);
me.disableEditing(me._state.hasValid || me._state.hasInvalid);
}, },
onSelectSignature: function(picker, item, record, e){ onSelectSignature: function(picker, item, record, e){
@ -232,7 +238,7 @@ define([
}); });
} }
var requested = record.get('requested'), var requested = record.get('requested'),
signed = (this._state.validSignatures.length>0 || this._state.invalidSignatures.length>0); signed = (this._state.hasValid || this._state.hasInvalid);
menu.items[0].setVisible(requested); menu.items[0].setVisible(requested);
menu.items[1].setVisible(!requested); menu.items[1].setVisible(!requested);
menu.items[2].setVisible(requested || !record.get('invisible')); menu.items[2].setVisible(requested || !record.get('invisible'));
@ -282,21 +288,36 @@ define([
this._state.ready = true; this._state.ready = true;
this.updateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures()); this.updateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures());
this.showSignatureTooltip(this._state.validSignatures.length>0, this._state.invalidSignatures.length>0, this._state.requestedSignatures.length>0); this.showSignatureTooltip(this._state.hasValid, this._state.hasInvalid, this._state.hasRequested);
}, },
showSignatureTooltip: function(hasValid, hasInvalid, hasRequested) { showSignatureTooltip: function(hasValid, hasInvalid, hasRequested) {
if (!hasValid && !hasInvalid && !hasRequested) return;
var tipText = (hasInvalid) ? this.txtSignedInvalid : (hasValid ? this.txtSigned : "");
if (hasRequested)
tipText = this.txtRequestedSignatures + "<br><br>" + tipText;
var me = this, var me = this,
tip = me._state.tip;
if (!hasValid && !hasInvalid && !hasRequested) {
if (tip && tip.isVisible()) {
tip.close();
me._state.tip = undefined;
}
return;
}
var showLink = hasValid || hasInvalid,
tipText = (hasInvalid) ? me.txtSignedInvalid : (hasValid ? me.txtSigned : "");
if (hasRequested)
tipText = me.txtRequestedSignatures + "<br><br>" + tipText;
if (tip && tip.isVisible() && (tipText !== tip.text || showLink !== tip.showLink)) {
tip.close();
me._state.tip = undefined;
}
if (!me._state.tip) {
tip = new Common.UI.SynchronizeTip({ tip = new Common.UI.SynchronizeTip({
target : DE.getController('RightMenu').getView('RightMenu').btnSignature.btnEl, target : DE.getController('RightMenu').getView('RightMenu').btnSignature.btnEl,
text : tipText, text : tipText,
showLink: hasValid || hasInvalid, showLink: showLink,
textLink: this.txtContinueEditing, textLink: this.txtContinueEditing,
placement: 'left' placement: 'left'
}); });
@ -310,6 +331,7 @@ define([
callback: function(btn) { callback: function(btn) {
if (btn == 'ok') { if (btn == 'ok') {
tip.close(); tip.close();
me._state.tip = undefined;
me.api.asc_RemoveAllSignatures(); me.api.asc_RemoveAllSignatures();
} }
} }
@ -317,9 +339,12 @@ define([
}, },
'closeclick': function() { 'closeclick': function() {
tip.close(); tip.close();
me._state.tip = undefined;
} }
}); });
me._state.tip = tip;
tip.show(); tip.show();
}
}, },
disableEditing: function(disable) { disableEditing: function(disable) {

View file

@ -293,6 +293,7 @@ button:active:not(.disabled) .btn-change-shape {background-position: -56px -
.signature-item { .signature-item {
padding: 5px 2px 5px 15px; padding: 5px 2px 5px 15px;
text-overflow: ellipsis; text-overflow: ellipsis;
min-height: 25px;
.name { .name {
width: 100%; width: 100%;
@ -312,11 +313,10 @@ button:active:not(.disabled) .btn-change-shape {background-position: -56px -
display: inline-block; display: inline-block;
position: absolute; position: absolute;
right: 0; right: 0;
}
&.requested { &.nomargin {
.caret { margin-top: 0;
margin: 0 15px; margin-bottom: 0;
} }
} }
} }

View file

@ -63,11 +63,11 @@ define([
initialize: function () { initialize: function () {
this._state = { this._state = {
requestedSignatures: undefined,
validSignatures: undefined,
invalidSignatures: undefined,
DisabledEditing: false, DisabledEditing: false,
ready: false ready: false,
hasValid: false,
hasInvalid: false,
tip: undefined
}; };
this._locked = false; this._locked = false;
@ -88,7 +88,7 @@ define([
enableKeyEvents: false, enableKeyEvents: false,
itemTemplate: _.template([ itemTemplate: _.template([
'<div id="<%= id %>" class="signature-item">', '<div id="<%= id %>" class="signature-item">',
'<div class="caret img-commonctrl"></div>', '<div class="caret img-commonctrl <% if (name == "" || date == "") { %>' + 'nomargin' + '<% } %>"></div>',
'<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>', '<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>',
'<div class="date"><%= Common.Utils.String.htmlEncode(date) %></div>', '<div class="date"><%= Common.Utils.String.htmlEncode(date) %></div>',
'</div>' '</div>'
@ -100,7 +100,7 @@ define([
enableKeyEvents: false, enableKeyEvents: false,
itemTemplate: _.template([ itemTemplate: _.template([
'<div id="<%= id %>" class="signature-item">', '<div id="<%= id %>" class="signature-item">',
'<div class="caret img-commonctrl"></div>', '<div class="caret img-commonctrl <% if (name == "" || date == "") { %>' + 'nomargin' + '<% } %>"></div>',
'<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>', '<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>',
'<div class="date"><%= Common.Utils.String.htmlEncode(date) %></div>', '<div class="date"><%= Common.Utils.String.htmlEncode(date) %></div>',
'</div>' '</div>'
@ -130,7 +130,7 @@ define([
}, },
ChangeSettings: function(props) { ChangeSettings: function(props) {
if (!this._state.validSignatures || !this._state.invalidSignatures) if (!this._state.hasValid && !this._state.hasInvalid)
this.updateSignatures(this.api.asc_getSignatures()); this.updateSignatures(this.api.asc_getSignatures());
}, },
@ -146,29 +146,33 @@ define([
if (!this._state.ready) return; if (!this._state.ready) return;
this.updateSignatures(valid); this.updateSignatures(valid);
this.showSignatureTooltip(this._state.validSignatures.length>0, this._state.invalidSignatures.length>0); this.showSignatureTooltip(this._state.hasValid, this._state.hasInvalid);
}, },
updateSignatures: function(valid){ updateSignatures: function(valid){
var me = this; var me = this,
me._state.validSignatures = []; validSignatures = [],
me._state.invalidSignatures = []; invalidSignatures = [];
_.each(valid, function(item, index){ _.each(valid, function(item, index){
var sign = {name: item.asc_getSigner1(), certificateId: item.asc_getId(), guid: item.asc_getGuid(), date: item.asc_getDate()}; var item_date = item.asc_getDate();
(item.asc_getValid()==0) ? me._state.validSignatures.push(sign) : me._state.invalidSignatures.push(sign); var sign = {name: item.asc_getSigner1(), certificateId: item.asc_getId(), guid: item.asc_getGuid(), date: (!_.isEmpty(item_date)) ? new Date(item_date).toLocaleString() : '', invisible: !item.asc_getVisible()};
(item.asc_getValid()==0) ? validSignatures.push(sign) : invalidSignatures.push(sign);
}); });
// me._state.validSignatures = [{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017', invisible: true}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}]; // validSignatures = [{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017', invisible: true}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}];
// me._state.invalidSignatures = [{name: 'Mary White', guid: '111', date: '18/05/2017'}, {name: 'John Black', guid: '456', date: '18/05/2017'}]; // invalidSignatures = [{name: 'Mary White', guid: '111', date: '18/05/2017'}, {name: 'John Black', guid: '456', date: '18/05/2017'}];
this.viewValidList.store.reset(me._state.validSignatures); me._state.hasValid = validSignatures.length>0;
this.viewInvalidList.store.reset(me._state.invalidSignatures); me._state.hasInvalid = invalidSignatures.length>0;
this.$el.find('.valid').toggleClass('hidden', me._state.validSignatures.length<1); this.viewValidList.store.reset(validSignatures);
this.$el.find('.invalid').toggleClass('hidden', me._state.invalidSignatures.length<1); this.viewInvalidList.store.reset(invalidSignatures);
me.disableEditing(me._state.validSignatures.length>0 || me._state.invalidSignatures.length>0); this.$el.find('.valid').toggleClass('hidden', !me._state.hasValid);
this.$el.find('.invalid').toggleClass('hidden', !me._state.hasInvalid);
me.disableEditing(me._state.hasValid || me._state.hasInvalid);
}, },
onSelectSignature: function(picker, item, record, e){ onSelectSignature: function(picker, item, record, e){
@ -244,19 +248,34 @@ define([
this._state.ready = true; this._state.ready = true;
this.updateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures()); this.updateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures());
this.showSignatureTooltip(this._state.validSignatures.length>0, this._state.invalidSignatures.length>0); this.showSignatureTooltip(this._state.hasValid, this._state.hasInvalid);
}, },
showSignatureTooltip: function(hasValid, hasInvalid) { showSignatureTooltip: function(hasValid, hasInvalid) {
if (!hasValid && !hasInvalid) return;
var tipText = (hasInvalid) ? this.txtSignedInvalid : (hasValid ? this.txtSigned : "");
var me = this, var me = this,
tip = me._state.tip;
if (!hasValid && !hasInvalid) {
if (tip && tip.isVisible()) {
tip.close();
me._state.tip = undefined;
}
return;
}
var showLink = hasValid || hasInvalid,
tipText = (hasInvalid) ? me.txtSignedInvalid : (hasValid ? me.txtSigned : "");
if (tip && tip.isVisible() && (tipText !== tip.text || showLink !== tip.showLink)) {
tip.close();
me._state.tip = undefined;
}
if (!me._state.tip) {
tip = new Common.UI.SynchronizeTip({ tip = new Common.UI.SynchronizeTip({
target : PE.getController('RightMenu').getView('RightMenu').btnSignature.btnEl, target : PE.getController('RightMenu').getView('RightMenu').btnSignature.btnEl,
text : tipText, text : tipText,
showLink: hasValid || hasInvalid, showLink: showLink,
textLink: this.txtContinueEditing, textLink: this.txtContinueEditing,
placement: 'left' placement: 'left'
}); });
@ -270,6 +289,7 @@ define([
callback: function(btn) { callback: function(btn) {
if (btn == 'ok') { if (btn == 'ok') {
tip.close(); tip.close();
me._state.tip = undefined;
me.api.asc_RemoveAllSignatures(); me.api.asc_RemoveAllSignatures();
} }
} }
@ -277,9 +297,12 @@ define([
}, },
'closeclick': function() { 'closeclick': function() {
tip.close(); tip.close();
me._state.tip = undefined;
} }
}); });
me._state.tip = tip;
tip.show(); tip.show();
}
}, },
disableEditing: function(disable) { disableEditing: function(disable) {

View file

@ -229,6 +229,7 @@ button:active:not(.disabled) .btn-change-shape {background-position: -56px -
.signature-item { .signature-item {
padding: 5px 2px 5px 15px; padding: 5px 2px 5px 15px;
text-overflow: ellipsis; text-overflow: ellipsis;
min-height: 25px;
.name { .name {
width: 100%; width: 100%;
@ -248,11 +249,10 @@ button:active:not(.disabled) .btn-change-shape {background-position: -56px -
display: inline-block; display: inline-block;
position: absolute; position: absolute;
right: 0; right: 0;
}
&.requested { &.nomargin {
.caret { margin-top: 0;
margin: 0 15px; margin-bottom: 0;
} }
} }
} }

View file

@ -63,11 +63,12 @@ define([
initialize: function () { initialize: function () {
this._state = { this._state = {
requestedSignatures: undefined,
validSignatures: undefined,
invalidSignatures: undefined,
DisabledEditing: false, DisabledEditing: false,
ready: false ready: false,
hasValid: false,
hasInvalid: false,
hasRequested: false,
tip: undefined
}; };
this._locked = false; this._locked = false;
@ -88,7 +89,7 @@ define([
enableKeyEvents: false, enableKeyEvents: false,
itemTemplate: _.template([ itemTemplate: _.template([
'<div id="<%= id %>" class="signature-item requested">', '<div id="<%= id %>" class="signature-item requested">',
'<div class="caret img-commonctrl"></div>', '<div class="caret img-commonctrl nomargin"></div>',
'<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>', '<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>',
'</div>' '</div>'
].join('')) ].join(''))
@ -99,7 +100,7 @@ define([
enableKeyEvents: false, enableKeyEvents: false,
itemTemplate: _.template([ itemTemplate: _.template([
'<div id="<%= id %>" class="signature-item">', '<div id="<%= id %>" class="signature-item">',
'<div class="caret img-commonctrl"></div>', '<div class="caret img-commonctrl <% if (name == "" || date == "") { %>' + 'nomargin' + '<% } %>"></div>',
'<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>', '<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>',
'<div class="date"><%= Common.Utils.String.htmlEncode(date) %></div>', '<div class="date"><%= Common.Utils.String.htmlEncode(date) %></div>',
'</div>' '</div>'
@ -111,7 +112,7 @@ define([
enableKeyEvents: false, enableKeyEvents: false,
itemTemplate: _.template([ itemTemplate: _.template([
'<div id="<%= id %>" class="signature-item">', '<div id="<%= id %>" class="signature-item">',
'<div class="caret img-commonctrl"></div>', '<div class="caret img-commonctrl <% if (name == "" || date == "") { %>' + 'nomargin' + '<% } %>"></div>',
'<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>', '<div class="name"><%= Common.Utils.String.htmlEncode(name) %></div>',
'<div class="date"><%= Common.Utils.String.htmlEncode(date) %></div>', '<div class="date"><%= Common.Utils.String.htmlEncode(date) %></div>',
'</div>' '</div>'
@ -144,7 +145,7 @@ define([
}, },
ChangeSettings: function(props) { ChangeSettings: function(props) {
if (!this._state.requestedSignatures || !this._state.validSignatures || !this._state.invalidSignatures) if (!this._state.hasRequested && !this._state.hasValid && !this._state.hasInvalid)
this.updateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures()); this.updateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures());
}, },
@ -160,36 +161,41 @@ define([
if (!this._state.ready) return; if (!this._state.ready) return;
this.updateSignatures(valid, requested); this.updateSignatures(valid, requested);
this.showSignatureTooltip(this._state.validSignatures.length>0, this._state.invalidSignatures.length>0); this.showSignatureTooltip(this._state.hasValid, this._state.hasInvalid);
}, },
updateSignatures: function(valid, requested){ updateSignatures: function(valid, requested){
var me = this; var me = this,
me._state.requestedSignatures = []; requestedSignatures = [],
me._state.validSignatures = []; validSignatures = [],
me._state.invalidSignatures = []; invalidSignatures = [];
_.each(requested, function(item, index){ _.each(requested, function(item, index){
me._state.requestedSignatures.push({name: item.asc_getSigner1(), guid: item.asc_getGuid(), requested: true}); requestedSignatures.push({name: item.asc_getSigner1(), guid: item.asc_getGuid(), requested: true});
}); });
_.each(valid, function(item, index){ _.each(valid, function(item, index){
var sign = {name: item.asc_getSigner1(), certificateId: item.asc_getId(), guid: item.asc_getGuid(), date: item.asc_getDate(), invisible: !item.asc_getVisible()}; var item_date = item.asc_getDate();
(item.asc_getValid()==0) ? me._state.validSignatures.push(sign) : me._state.invalidSignatures.push(sign); var sign = {name: item.asc_getSigner1(), certificateId: item.asc_getId(), guid: item.asc_getGuid(), date: (!_.isEmpty(item_date)) ? new Date(item_date).toLocaleString() : '', invisible: !item.asc_getVisible()};
(item.asc_getValid()==0) ? validSignatures.push(sign) : invalidSignatures.push(sign);
}); });
// me._state.requestedSignatures = [{name: 'Hammish Mitchell', guid: '123', requested: true}, {name: 'Someone Somewhere', guid: '123', requested: true}, {name: 'Mary White', guid: '123', requested: true}, {name: 'John Black', guid: '123', requested: true}]; // requestedSignatures = [{name: 'Hammish Mitchell', guid: '123', requested: true}, {name: 'Someone Somewhere', guid: '123', requested: true}, {name: 'Mary White', guid: '123', requested: true}, {name: 'John Black', guid: '123', requested: true}];
// me._state.validSignatures = [{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017', invisible: true}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}]; // validSignatures = [{name: 'Hammish Mitchell', guid: '123', date: '18/05/2017', invisible: true}, {name: 'Someone Somewhere', guid: '345', date: '18/05/2017'}];
// me._state.invalidSignatures = [{name: 'Mary White', guid: '111', date: '18/05/2017'}, {name: 'John Black', guid: '456', date: '18/05/2017'}]; // invalidSignatures = [{name: 'Mary White', guid: '111', date: '18/05/2017'}, {name: 'John Black', guid: '456', date: '18/05/2017'}];
this.viewRequestedList.store.reset(me._state.requestedSignatures); me._state.hasValid = validSignatures.length>0;
this.viewValidList.store.reset(me._state.validSignatures); me._state.hasInvalid = invalidSignatures.length>0;
this.viewInvalidList.store.reset(me._state.invalidSignatures); me._state.hasRequested = requestedSignatures.length>0;
this.$el.find('.requested').toggleClass('hidden', me._state.requestedSignatures.length<1); this.viewRequestedList.store.reset(requestedSignatures);
this.$el.find('.valid').toggleClass('hidden', me._state.validSignatures.length<1); this.viewValidList.store.reset(validSignatures);
this.$el.find('.invalid').toggleClass('hidden', me._state.invalidSignatures.length<1); this.viewInvalidList.store.reset(invalidSignatures);
me.disableEditing(me._state.validSignatures.length>0 || me._state.invalidSignatures.length>0); this.$el.find('.requested').toggleClass('hidden', !me._state.hasRequested);
this.$el.find('.valid').toggleClass('hidden', !me._state.hasValid);
this.$el.find('.invalid').toggleClass('hidden', !me._state.hasInvalid);
me.disableEditing(me._state.hasValid || me._state.hasInvalid);
}, },
onSelectSignature: function(picker, item, record, e){ onSelectSignature: function(picker, item, record, e){
@ -232,7 +238,7 @@ define([
}); });
} }
var requested = record.get('requested'), var requested = record.get('requested'),
signed = (this._state.validSignatures.length>0 || this._state.invalidSignatures.length>0); signed = (this._state.hasValid || this._state.hasInvalid);
menu.items[0].setVisible(requested); menu.items[0].setVisible(requested);
menu.items[1].setVisible(!requested); menu.items[1].setVisible(!requested);
menu.items[2].setVisible(requested || !record.get('invisible')); menu.items[2].setVisible(requested || !record.get('invisible'));
@ -282,21 +288,36 @@ define([
this._state.ready = true; this._state.ready = true;
this.updateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures()); this.updateSignatures(this.api.asc_getSignatures(), this.api.asc_getRequestSignatures());
this.showSignatureTooltip(this._state.validSignatures.length>0, this._state.invalidSignatures.length>0, this._state.requestedSignatures.length>0); this.showSignatureTooltip(this._state.hasValid, this._state.hasInvalid, this._state.hasRequested);
}, },
showSignatureTooltip: function(hasValid, hasInvalid, hasRequested) { showSignatureTooltip: function(hasValid, hasInvalid, hasRequested) {
if (!hasValid && !hasInvalid && !hasRequested) return;
var tipText = (hasInvalid) ? this.txtSignedInvalid : (hasValid ? this.txtSigned : "");
if (hasRequested)
tipText = this.txtRequestedSignatures + "<br><br>" + tipText;
var me = this, var me = this,
tip = me._state.tip;
if (!hasValid && !hasInvalid && !hasRequested) {
if (tip && tip.isVisible()) {
tip.close();
me._state.tip = undefined;
}
return;
}
var showLink = hasValid || hasInvalid,
tipText = (hasInvalid) ? me.txtSignedInvalid : (hasValid ? me.txtSigned : "");
if (hasRequested)
tipText = me.txtRequestedSignatures + "<br><br>" + tipText;
if (tip && tip.isVisible() && (tipText !== tip.text || showLink !== tip.showLink)) {
tip.close();
me._state.tip = undefined;
}
if (!me._state.tip) {
tip = new Common.UI.SynchronizeTip({ tip = new Common.UI.SynchronizeTip({
target : SSE.getController('RightMenu').getView('RightMenu').btnSignature.btnEl, target : SSE.getController('RightMenu').getView('RightMenu').btnSignature.btnEl,
text : tipText, text : tipText,
showLink: hasValid || hasInvalid, showLink: showLink,
textLink: this.txtContinueEditing, textLink: this.txtContinueEditing,
placement: 'left' placement: 'left'
}); });
@ -310,6 +331,7 @@ define([
callback: function(btn) { callback: function(btn) {
if (btn == 'ok') { if (btn == 'ok') {
tip.close(); tip.close();
me._state.tip = undefined;
me.api.asc_RemoveAllSignatures(); me.api.asc_RemoveAllSignatures();
} }
} }
@ -317,9 +339,12 @@ define([
}, },
'closeclick': function() { 'closeclick': function() {
tip.close(); tip.close();
me._state.tip = undefined;
} }
}); });
me._state.tip = tip;
tip.show(); tip.show();
}
}, },
disableEditing: function(disable) { disableEditing: function(disable) {

View file

@ -415,6 +415,7 @@ button:active:not(.disabled) .btn-change-shape {background-position: -56px -
.signature-item { .signature-item {
padding: 5px 2px 5px 15px; padding: 5px 2px 5px 15px;
text-overflow: ellipsis; text-overflow: ellipsis;
min-height: 25px;
.name { .name {
width: 100%; width: 100%;
@ -434,11 +435,10 @@ button:active:not(.disabled) .btn-change-shape {background-position: -56px -
display: inline-block; display: inline-block;
position: absolute; position: absolute;
right: 0; right: 0;
}
&.requested { &.nomargin {
.caret { margin-top: 0;
margin: 0 15px; margin-bottom: 0;
} }
} }
} }