[DE] Use sdk methods
This commit is contained in:
parent
041557e6a3
commit
96cc66875e
|
@ -46,13 +46,6 @@ define([
|
||||||
], function () {
|
], function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
Asc.c_oAscProtection = {
|
|
||||||
View: 1,
|
|
||||||
Forms: 2,
|
|
||||||
Review: 3,
|
|
||||||
Comments: 4
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!Common.enumLock)
|
if (!Common.enumLock)
|
||||||
Common.enumLock = {};
|
Common.enumLock = {};
|
||||||
|
|
||||||
|
@ -94,7 +87,7 @@ define([
|
||||||
setApi: function (api) {
|
setApi: function (api) {
|
||||||
if (api) {
|
if (api) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.api.asc_registerCallback('asc_onChangeProtectDocument',_.bind(this.onChangeProtectDocument, this));
|
this.api.asc_registerCallback('asc_onChangeDocumentProtection',_.bind(this.onChangeProtectDocument, this));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -128,14 +121,7 @@ define([
|
||||||
handler: function(result, value, props) {
|
handler: function(result, value, props) {
|
||||||
btn = result;
|
btn = result;
|
||||||
if (result == 'ok') {
|
if (result == 'ok') {
|
||||||
// var props = me.api.asc_getProtectedDocument();
|
me.api.asc_setDocumentProtection(props, value);
|
||||||
// props.asc_setType(props);
|
|
||||||
// props.asc_setLockPwd(value);
|
|
||||||
// me.api.asc_setProtectedDocument(props);
|
|
||||||
|
|
||||||
Common.Utils.InternalSettings.set('protect-test-type', props);
|
|
||||||
me.view.btnProtectDoc.toggle(true, true); // test
|
|
||||||
me.onChangeProtectDocument(); // test
|
|
||||||
}
|
}
|
||||||
Common.NotificationCenter.trigger('edit:complete');
|
Common.NotificationCenter.trigger('edit:complete');
|
||||||
}
|
}
|
||||||
|
@ -148,10 +134,8 @@ define([
|
||||||
} else {
|
} else {
|
||||||
var me = this,
|
var me = this,
|
||||||
btn,
|
btn,
|
||||||
// props = me.api.asc_getProtectedDocument();
|
props = me.api.asc_getDocumentProtection();
|
||||||
props = undefined; // test
|
if (props && props[1]) {
|
||||||
// if (props.asc_isPassword()) {
|
|
||||||
if (props && props.asc_isPassword()) {
|
|
||||||
var win = new Common.Views.OpenDialog({
|
var win = new Common.Views.OpenDialog({
|
||||||
title: me.view.txtWBUnlockTitle,
|
title: me.view.txtWBUnlockTitle,
|
||||||
closable: true,
|
closable: true,
|
||||||
|
@ -162,8 +146,7 @@ define([
|
||||||
btn = result;
|
btn = result;
|
||||||
if (result == 'ok') {
|
if (result == 'ok') {
|
||||||
if (me.api) {
|
if (me.api) {
|
||||||
// props.asc_setLockPwd(value && value.drmOptions ? value.drmOptions.asc_getPassword() : undefined);
|
me.api.asc_setProtectedDocument(Asc.c_oAscEDocProtect.None, value && value.drmOptions ? value.drmOptions.asc_getPassword() : undefined);
|
||||||
// me.api.asc_setProtectedDocument(props);
|
|
||||||
}
|
}
|
||||||
Common.NotificationCenter.trigger('edit:complete');
|
Common.NotificationCenter.trigger('edit:complete');
|
||||||
}
|
}
|
||||||
|
@ -175,10 +158,7 @@ define([
|
||||||
|
|
||||||
win.show();
|
win.show();
|
||||||
} else {
|
} else {
|
||||||
me.view.btnProtectDoc.toggle(false, true); // test
|
me.api.asc_setProtectedDocument(Asc.c_oAscEDocProtect.None);
|
||||||
me.onChangeProtectDocument(); // test
|
|
||||||
// props.asc_setLockPwd();
|
|
||||||
// me.api.asc_setProtectedDocument(props);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -190,46 +170,33 @@ define([
|
||||||
(new Promise(function (resolve) {
|
(new Promise(function (resolve) {
|
||||||
resolve();
|
resolve();
|
||||||
})).then(function () {
|
})).then(function () {
|
||||||
// me.view.btnProtectDoc.toggle(me.api.asc_isProtectedDocument(), true);
|
var props = me.api.asc_getDocumentProtection(),
|
||||||
|
isProtected = props && (props[0] === Asc.c_oAscEDocProtect.ReadOnly || props[0] === Asc.c_oAscEDocProtect.Comments ||
|
||||||
|
props[0] === Asc.c_oAscEDocProtect.TrackedChanges || props[0] === Asc.c_oAscEDocProtect.Forms);
|
||||||
|
|
||||||
|
me.view.btnProtectDoc.toggle(!!isProtected, true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onChangeProtectDocument: function() {
|
onChangeProtectDocument: function() {
|
||||||
// var isProtected = this.api.asc_isProtectedDocument();
|
var props = this.getDocProps(true),
|
||||||
var isProtected = this.view ? this.view.btnProtectDoc.isActive() : false; // test
|
isProtected = props && (props[0] === Asc.c_oAscEDocProtect.ReadOnly || props[0] === Asc.c_oAscEDocProtect.Comments ||
|
||||||
|
props[0] === Asc.c_oAscEDocProtect.TrackedChanges || props[0] === Asc.c_oAscEDocProtect.Forms);
|
||||||
this.view && this.view.btnProtectDoc.toggle(isProtected, true);
|
this.view && this.view.btnProtectDoc.toggle(isProtected, true);
|
||||||
Common.NotificationCenter.trigger('protect:doclock', this.getDocProps(true));
|
Common.NotificationCenter.trigger('protect:doclock', props);
|
||||||
},
|
},
|
||||||
|
|
||||||
getDocProps: function(update) {
|
getDocProps: function(update) {
|
||||||
if (!this.appConfig || !this.appConfig.isEdit && !this.appConfig.isRestrictedEdit) return;
|
if (!this.appConfig || !this.appConfig.isEdit && !this.appConfig.isRestrictedEdit) return;
|
||||||
|
|
||||||
if (update || !this._state.docProtection) {
|
if (update || !this._state.docProtection) {
|
||||||
// var docProtected = !!this.api.asc_isProtectedDocument(),
|
var props = this.api.asc_getDocumentProtection(),
|
||||||
// type;
|
type = props ? props[0] : Asc.c_oAscEDocProtect.None;
|
||||||
//
|
|
||||||
// if (docProtected) {
|
|
||||||
// var props = this.api.asc_getProtectedDocument();
|
|
||||||
// type = props.asc_getType();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// test //////
|
|
||||||
if (Common.Utils.InternalSettings.get('protect-test-type')===undefined) {
|
|
||||||
this.view && this.view.btnProtectDoc.toggle(true, true);
|
|
||||||
Common.Utils.InternalSettings.set('protect-test-type', Asc.c_oAscProtection.Forms);
|
|
||||||
}
|
|
||||||
var docProtected = this.view ? this.view.btnProtectDoc.isActive() : true,
|
|
||||||
type;
|
|
||||||
|
|
||||||
if (docProtected) {
|
|
||||||
type = Common.Utils.InternalSettings.get('protect-test-type');
|
|
||||||
}
|
|
||||||
/////////////
|
|
||||||
this._state.docProtection = {
|
this._state.docProtection = {
|
||||||
isReadOnly: type===Asc.c_oAscProtection.View,
|
isReadOnly: type===Asc.c_oAscEDocProtect.ReadOnly,
|
||||||
isCommentsOnly: type===Asc.c_oAscProtection.Comments,
|
isCommentsOnly: type===Asc.c_oAscEDocProtect.Comments,
|
||||||
isReviewOnly: type===Asc.c_oAscProtection.Review,
|
isReviewOnly: type===Asc.c_oAscEDocProtect.TrackedChanges,
|
||||||
isFormsOnly: type===Asc.c_oAscProtection.Forms
|
isFormsOnly: type===Asc.c_oAscEDocProtect.Forms
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return this._state.docProtection;
|
return this._state.docProtection;
|
||||||
|
|
|
@ -121,7 +121,7 @@ define([
|
||||||
el: this.$window.find('#id-protect-radio-view'),
|
el: this.$window.find('#id-protect-radio-view'),
|
||||||
labelText: this.textView,
|
labelText: this.textView,
|
||||||
name: 'asc-radio-protect-mode',
|
name: 'asc-radio-protect-mode',
|
||||||
value: Asc.c_oAscProtection.View,
|
value: Asc.c_oAscEDocProtect.ReadOnly,
|
||||||
checked: true
|
checked: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -129,21 +129,21 @@ define([
|
||||||
el: this.$window.find('#id-protect-radio-forms'),
|
el: this.$window.find('#id-protect-radio-forms'),
|
||||||
labelText: this.textForms,
|
labelText: this.textForms,
|
||||||
name: 'asc-radio-protect-mode',
|
name: 'asc-radio-protect-mode',
|
||||||
value: Asc.c_oAscProtection.Forms
|
value: Asc.c_oAscEDocProtect.Forms
|
||||||
});
|
});
|
||||||
|
|
||||||
this.rbReview = new Common.UI.RadioBox({
|
this.rbReview = new Common.UI.RadioBox({
|
||||||
el: this.$window.find('#id-protect-radio-review'),
|
el: this.$window.find('#id-protect-radio-review'),
|
||||||
labelText: this.textReview,
|
labelText: this.textReview,
|
||||||
name: 'asc-radio-protect-mode',
|
name: 'asc-radio-protect-mode',
|
||||||
value: Asc.c_oAscProtection.Review
|
value: Asc.c_oAscEDocProtect.TrackedChanges
|
||||||
});
|
});
|
||||||
|
|
||||||
this.rbComments = new Common.UI.RadioBox({
|
this.rbComments = new Common.UI.RadioBox({
|
||||||
el: this.$window.find('#id-protect-radio-comment'),
|
el: this.$window.find('#id-protect-radio-comment'),
|
||||||
labelText: this.textComments,
|
labelText: this.textComments,
|
||||||
name: 'asc-radio-protect-mode',
|
name: 'asc-radio-protect-mode',
|
||||||
value: Asc.c_oAscProtection.Comments
|
value: Asc.c_oAscEDocProtect.Comments
|
||||||
});
|
});
|
||||||
|
|
||||||
this.afterRender();
|
this.afterRender();
|
||||||
|
@ -199,13 +199,13 @@ define([
|
||||||
|
|
||||||
getSettings: function() {
|
getSettings: function() {
|
||||||
if (this.rbView.getValue())
|
if (this.rbView.getValue())
|
||||||
return Asc.c_oAscProtection.View;
|
return Asc.c_oAscEDocProtect.ReadOnly;
|
||||||
if (this.rbForms.getValue())
|
if (this.rbForms.getValue())
|
||||||
return Asc.c_oAscProtection.Forms;
|
return Asc.c_oAscEDocProtect.Forms;
|
||||||
if (this.rbReview.getValue())
|
if (this.rbReview.getValue())
|
||||||
return Asc.c_oAscProtection.Review;
|
return Asc.c_oAscEDocProtect.TrackedChanges;
|
||||||
if (this.rbComments.getValue())
|
if (this.rbComments.getValue())
|
||||||
return Asc.c_oAscProtection.Comments;
|
return Asc.c_oAscEDocProtect.Comments;
|
||||||
},
|
},
|
||||||
|
|
||||||
txtPassword : "Password",
|
txtPassword : "Password",
|
||||||
|
|
Loading…
Reference in a new issue