Skip to content

Commit

Permalink
fix/[de,pe,de]: remove apply button
Browse files Browse the repository at this point in the history
  • Loading branch information
sekiju committed Sep 18, 2024
1 parent e91e4ae commit 39197ed
Show file tree
Hide file tree
Showing 10 changed files with 302 additions and 270 deletions.
18 changes: 11 additions & 7 deletions apps/common/main/lib/view/DocumentPropertyDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,17 @@ define([], function () { 'use strict';
render: function() {
Common.UI.Window.prototype.render.call(this);

var me = this;
this.inputTitle = new Common.UI.InputField({
el: $('#id-dlg-title'),
allowBlank: false,
blankError: this.txtPropertyTitleBlankError,
validateOnBlur: false,
hideErrorOnInput: true,
validation: function(value) {
return value.length === 0 ? this.txtPropertyTitleBlankError : true;
if (me.options.nameValidator !== undefined) {
return me.options.nameValidator(value);
}
}
});
if (this.options.defaultValue.name) {
Expand All @@ -111,7 +115,8 @@ define([], function () { 'use strict';
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big',
ariaLabel: this.strLineHeight
ariaLabel: this.strLineHeight,
takeFocusOnClose: true
});
var currentType = this.options.defaultValue.type ? this.asc2type(this.options.defaultValue.type) : 'text'
this.comboboxType.setValue(currentType);
Expand All @@ -126,11 +131,9 @@ define([], function () { 'use strict';
style: 'width: 100%;',
validateOnBlur: false,
hideErrorOnInput: true,
allowBlank: false,
blankError: this.txtPropertyValueBlankError,
validation: function(value) {
if (value.length === 0) {
return this.txtPropertyValueBlankError;
}

if (this.comboboxType.getValue() === 'number' && (typeof value !== 'number' && isNaN(value.replace(',', '.')))) {
return this.txtPropertyTypeNumberInvalid;
}
Expand Down Expand Up @@ -159,7 +162,8 @@ define([], function () { 'use strict';
dataHint: '1',
dataHintDirection: 'bottom',
dataHintOffset: 'big',
ariaLabel: this.strLineHeight
ariaLabel: this.strLineHeight,
takeFocusOnClose: true
});
this.comboboxBoolean.setValue(this.options.defaultValue.value !== undefined && currentType === 'boolean' ? (this.options.defaultValue.value ? 1 : 0) : 1);
this.comboboxBoolean.setVisible(this.options.defaultValue.type ? this.options.defaultValue.type === AscCommon.c_oVariantTypes.vtBool : currentType === 'boolean');
Expand Down
169 changes: 85 additions & 84 deletions apps/documenteditor/main/app/view/FileMenuPanels.js
Original file line number Diff line number Diff line change
Expand Up @@ -1470,16 +1470,6 @@ define([], function () {
'</tr>',
'</table>',
'</div>',
'<div id="fms-flex-apply">',
'<table class="main">',
'<tr>',
'<td class="left"></td>',
'<td class="right">',
'<button id="fminfo-btn-apply" class="btn normal dlg-btn primary" data-hint="2" data-hint-direction="bottom" data-hint-offset="big"><%= scope.okButtonText %></button>',
'</td>',
'</tr>',
'</table>',
'</div>'
].join(''));

this.infoObj = {PageCount: 0, WordsCount: 0, ParagraphCount: 0, SymbolsCount: 0, SymbolsWSCount:0};
Expand Down Expand Up @@ -1537,7 +1527,11 @@ define([], function () {
dataHintDirection: 'left',
dataHintOffset: 'small',
ariaLabel: this.txtTitle
}).on('keydown:before', keyDownBefore);
}).on('keydown:before', keyDownBefore).on('changed:after', function(_, newValue) {
me.coreProps.asc_putTitle(newValue);
me.api.asc_setCoreProps(me.coreProps);
});

this.inputTags = new Common.UI.InputField({
el : $markup.findById('#id-info-tags'),
style : 'width: 200px;',
Expand All @@ -1547,7 +1541,11 @@ define([], function () {
dataHintDirection: 'left',
dataHintOffset: 'small',
ariaLabel: this.txtTags
}).on('keydown:before', keyDownBefore);
}).on('keydown:before', keyDownBefore).on('changed:after', function(_, newValue) {
me.coreProps.asc_putKeywords(newValue);
me.api.asc_setCoreProps(me.coreProps);
});

this.inputSubject = new Common.UI.InputField({
el : $markup.findById('#id-info-subject'),
style : 'width: 200px;',
Expand All @@ -1557,7 +1555,11 @@ define([], function () {
dataHintDirection: 'left',
dataHintOffset: 'small',
ariaLabel: this.txtSubject
}).on('keydown:before', keyDownBefore);
}).on('keydown:before', keyDownBefore).on('changed:after', function(_, newValue) {
me.coreProps.asc_putSubject(newValue);
me.api.asc_setCoreProps(me.coreProps);
});

this.inputComment = new Common.UI.InputField({
el : $markup.findById('#id-info-comment'),
style : 'width: 200px;',
Expand All @@ -1567,7 +1569,10 @@ define([], function () {
dataHintDirection: 'left',
dataHintOffset: 'small',
ariaLabel: this.txtComment
}).on('keydown:before', keyDownBefore);
}).on('keydown:before', keyDownBefore).on('changed:after', function(_, newValue) {
me.coreProps.asc_putDescription(newValue);
me.api.asc_setCoreProps(me.coreProps);
});

// modify info
this.lblModifyDate = $markup.findById('#id-info-modify-date');
Expand All @@ -1587,6 +1592,8 @@ define([], function () {
idx = me.tblAuthor.find('tr').index(el);
el.remove();
me.authors.splice(idx, 1);
me.coreProps.asc_putCreator(me.authors.join(';'));
me.api.asc_setCoreProps(me.coreProps);
me.updateScroller(true);
}
});
Expand Down Expand Up @@ -1619,6 +1626,9 @@ define([], function () {
});
!isFromApply && me.inputAuthor.setValue('');
}

me.coreProps.asc_putCreator(me.authors.join(';'));
me.api.asc_setCoreProps(me.coreProps);
}).on('keydown:before', keyDownBefore);

// pdf info
Expand All @@ -1631,18 +1641,11 @@ define([], function () {
this.lblPdfProducer = $markup.findById('#id-info-pdf-produce');
this.lblFastWV = $markup.findById('#id-info-fast-wv');

this.btnApply = new Common.UI.Button({
el: $markup.findById('#fminfo-btn-apply')
});
this.btnApply.on('click', _.bind(this.applySettings, this));

this.btnAddProperty = new Common.UI.Button({
el: $markup.findById('#fminfo-btn-add-property')
});
this.btnAddProperty.on('click', _.bind(this.onAddPropertyClick, this));

this.pnlApply = $markup.findById('#fms-flex-apply');

this.rendered = true;

this.updateInfo(this.doc);
Expand Down Expand Up @@ -1730,12 +1733,8 @@ define([], function () {
this._ShowHideInfoItem(this.lblDate, !!value);
} else if (pdfProps)
this.updatePdfInfo(pdfProps);

if (this.api) {
_.each(this.api.asc_getAllCustomProperties(), _.bind(function(prop, idx) {
this.renderCustomProperty(prop.asc_getName(), prop.asc_getType(), prop.asc_getValue(), idx);
}, this));
}

this.renderCustomProperties();
},

updateFileInfo: function() {
Expand Down Expand Up @@ -1898,7 +1897,7 @@ define([], function () {
setMode: function(mode) {
this.mode = mode;
this.inputAuthor.setVisible(mode.isEdit);
this.pnlApply.toggleClass('hidden', !mode.isEdit);
this.btnAddProperty.setVisible(mode.isEdit);
this.tblAuthor.find('.close').toggleClass('hidden', !mode.isEdit);
this.inputTitle._input.attr('placeholder', mode.isEdit ? this.txtAddText : '');
this.inputTags._input.attr('placeholder', mode.isEdit ? this.txtAddText : '');
Expand Down Expand Up @@ -1962,10 +1961,10 @@ define([], function () {
value = this.dateToString(new Date(value), true);
}

return '<tr data-name="' + name +'">' +
return '<tr data-custom-property>' +
'<td class="left"><label>' + name + '</label></td>' +
'<td class="right"><div class="custom-property-wrapper">' +
'<input type="text" spellcheck="false" class="form-control" readonly style="width: 200px;" value="' + value +'">' +
'<input type="text" spellcheck="false" class="form-control" readonly style="width: 200px;" value="' + Common.Utils.String.htmlEncode(value) +'">' +
'<div class="tool close img-colored" data-hint="2" data-hint-direction="right" data-hint-offset="small"></div>' +
'</div></td></tr>';
},
Expand All @@ -1985,49 +1984,59 @@ define([], function () {
return text;
},

renderCustomProperty: function(name, type, value, idx) {
var me = this;

var currentCustomProperty = $('tr[data-name="' + name + '"]');
if (currentCustomProperty.length) {
currentCustomProperty.off('click');
currentCustomProperty.html($(this.tplCustomProperty(name, type, value)));
} else {
currentCustomProperty = $(this.tplCustomProperty(name, type, value));
$('tbody.properties-tab').append(currentCustomProperty);
renderCustomProperties: function() {
if (!this.api) {
return;
}

currentCustomProperty.on('click', function (e) {
if (currentCustomProperty.find('div.disabled').length) {
return;
}
$('tr[data-custom-property]').remove();

var properties = this.api.asc_getAllCustomProperties();
_.each(properties, _.bind(function(prop, idx) {
var me = this, name = prop.asc_getName(), type = prop.asc_getType(), value = prop.asc_getValue();
var $propertyEl = $(this.tplCustomProperty(name, type, value));

var btn = currentCustomProperty.find(e.target);
if (btn.hasClass('close')) {
me.api.asc_removeCustomProperty(idx);
$('tr[data-name="' + name + '"]').remove();
} else if (btn.hasClass('form-control')) {
(new Common.Views.DocumentPropertyDialog({
title: me.txtDocumentPropertyUpdateTitle,
lang: me.mode.lang,
defaultValue: {
name: name,
type: type,
value: value
},
handler: function(result, name, type, value) {
if (result === 'ok') {
me.api.asc_modifyCustomProperty(idx, name, type, value);
me.renderCustomProperty(name, type, value, idx);
$('tbody.properties-tab').append($propertyEl);

$propertyEl.on('click', function (e) {
if ($propertyEl.find('div.disabled').length) {
return;
}

var btn = $propertyEl.find(e.target);
if (btn.hasClass('close')) {
me.api.asc_removeCustomProperty(idx);
me.renderCustomProperties();
} else if (btn.hasClass('form-control')) {
(new Common.Views.DocumentPropertyDialog({
title: me.txtDocumentPropertyUpdateTitle,
lang: me.mode.lang,
defaultValue: {
name: name,
type: type,
value: value
},
nameValidator: function(newName) {
if (newName !== name && _.some(properties, function (prop) { return prop.name === newName; })) {
return me.txtPropertyTitleConflictError;
}

return true;
},
handler: function(result, name, type, value) {
if (result === 'ok') {
me.api.asc_modifyCustomProperty(idx, name, type, value);
me.renderCustomProperties();
}
}
}
})).show();
}
})
})).show();
}
});
}, this));
},

setDisabledCustomProperties: function(disable) {
_.each($('tr[data-name]'), function(prop) {
_.each($('tr[data-custom-property]'), function(prop) {
$(prop).find('div.custom-property-wrapper')[disable ? 'addClass' : 'removeClass']('disabled');
$(prop).find('div.close')[disable ? 'hide' : 'show']();
})
Expand Down Expand Up @@ -2070,7 +2079,6 @@ define([], function () {
this.inputAuthor.setDisabled(disable);
this.tblAuthor.find('.close').toggleClass('disabled', this._state._locked);
this.tblAuthor.toggleClass('disabled', disable);
this.btnApply.setDisabled(this._state._locked);
this.btnAddProperty.setDisabled(disable);
this.setDisabledCustomProperties(disable);
},
Expand All @@ -2079,31 +2087,23 @@ define([], function () {
var me = this;
(new Common.Views.DocumentPropertyDialog({
lang: me.mode.lang,
nameValidator: function(newName) {
var properties = me.api.asc_getAllCustomProperties();
if (_.some(properties, function (prop) { return prop.name === newName; })) {
return me.txtPropertyTitleConflictError;
}

return true;
},
handler: function(result, title, type, value) {
if (result === 'ok') {
me.api.asc_addCustomProperty(title, type, value);
var properties = me.api.asc_getAllCustomProperties();
if (properties.length) {
var prop = properties[properties.length - 1];
me.renderCustomProperty(prop.asc_getName(), prop.asc_getType(), prop.asc_getValue(), properties.length - 1);
}
me.renderCustomProperties();
}
}
})).show();
},

applySettings: function() {
if (this.coreProps && this.api) {
this.coreProps.asc_putTitle(this.inputTitle.getValue());
this.coreProps.asc_putKeywords(this.inputTags.getValue());
this.coreProps.asc_putSubject(this.inputSubject.getValue());
this.coreProps.asc_putDescription(this.inputComment.getValue());
this.coreProps.asc_putCreator(this.authors.join(';'));
this.api.asc_setCoreProps(this.coreProps);
}
this.menu.hide();
},

txtPlacement: 'Location',
txtOwner: 'Owner',
txtUploaded: 'Uploaded',
Expand Down Expand Up @@ -2139,6 +2139,7 @@ define([], function () {
txtProperties: 'Properties',
txtDocumentInfo: 'Document Info',
txtDocumentPropertyUpdateTitle: "Document Property",
txtPropertyTitleConflictError: 'Property with this title already exists',
txtAddProperty: 'Add property'

}, DE.Views.FileMenuPanels.DocumentInfo || {}));
Expand Down
1 change: 1 addition & 0 deletions apps/documenteditor/main/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2194,6 +2194,7 @@
"DE.Views.FileMenuPanels.DocumentInfo.txtProperties": "Properties",
"DE.Views.FileMenuPanels.DocumentInfo.txtDocumentPropertyUpdateTitle": "Document Property",
"DE.Views.FileMenuPanels.DocumentInfo.txtAddProperty": "Add property",
"DE.Views.FileMenuPanels.DocumentInfo.txtPropertyTitleConflictError": "Property with this title already exists",
"DE.Views.FileMenuPanels.DocumentRights.txtAccessRights": "Access rights",
"DE.Views.FileMenuPanels.DocumentRights.txtBtnAccessRights": "Change access rights",
"DE.Views.FileMenuPanels.DocumentRights.txtRights": "Persons who have rights",
Expand Down
Loading

0 comments on commit 39197ed

Please sign in to comment.