[DE] Bug 36585: insert date/time

This commit is contained in:
Julia Radzhabova 2020-03-03 11:08:15 +03:00
parent 63771420f4
commit b20217d187
11 changed files with 302 additions and 4 deletions

View file

@ -58,7 +58,8 @@ define([
'documenteditor/main/app/view/CustomColumnsDialog', 'documenteditor/main/app/view/CustomColumnsDialog',
'documenteditor/main/app/view/ControlSettingsDialog', 'documenteditor/main/app/view/ControlSettingsDialog',
'documenteditor/main/app/view/WatermarkSettingsDialog', 'documenteditor/main/app/view/WatermarkSettingsDialog',
'documenteditor/main/app/view/CompareSettingsDialog' 'documenteditor/main/app/view/CompareSettingsDialog',
'documenteditor/main/app/view/DateTimeDialog'
], function () { ], function () {
'use strict'; 'use strict';
@ -318,6 +319,7 @@ define([
toolbar.btnMailRecepients.on('click', _.bind(this.onSelectRecepientsClick, this)); toolbar.btnMailRecepients.on('click', _.bind(this.onSelectRecepientsClick, this));
toolbar.mnuPageNumberPosPicker.on('item:click', _.bind(this.onInsertPageNumberClick, this)); toolbar.mnuPageNumberPosPicker.on('item:click', _.bind(this.onInsertPageNumberClick, this));
toolbar.btnEditHeader.menu.on('item:click', _.bind(this.onEditHeaderFooterClick, this)); toolbar.btnEditHeader.menu.on('item:click', _.bind(this.onEditHeaderFooterClick, this));
toolbar.btnInsDateTime.on('click', _.bind(this.onInsDateTimeClick, this));
toolbar.mnuPageNumCurrentPos.on('click', _.bind(this.onPageNumCurrentPosClick, this)); toolbar.mnuPageNumCurrentPos.on('click', _.bind(this.onPageNumCurrentPosClick, this));
toolbar.mnuInsertPageCount.on('click', _.bind(this.onInsertPageCountClick, this)); toolbar.mnuInsertPageCount.on('click', _.bind(this.onInsertPageCountClick, this));
toolbar.btnBlankPage.on('click', _.bind(this.onBtnBlankPageClick, this)); toolbar.btnBlankPage.on('click', _.bind(this.onBtnBlankPageClick, this));
@ -829,6 +831,7 @@ define([
toolbar.btnInsertEquation.setDisabled(need_disable); toolbar.btnInsertEquation.setDisabled(need_disable);
toolbar.btnInsertSymbol.setDisabled(!in_para || paragraph_locked || header_locked || rich_edit_lock || plain_edit_lock || rich_del_lock || plain_del_lock); toolbar.btnInsertSymbol.setDisabled(!in_para || paragraph_locked || header_locked || rich_edit_lock || plain_edit_lock || rich_del_lock || plain_del_lock);
toolbar.btnInsDateTime.setDisabled(!in_para || paragraph_locked || header_locked || rich_edit_lock || plain_edit_lock || rich_del_lock || plain_del_lock);
need_disable = paragraph_locked || header_locked || in_equation || rich_edit_lock || plain_edit_lock; need_disable = paragraph_locked || header_locked || in_equation || rich_edit_lock || plain_edit_lock;
toolbar.btnSuperscript.setDisabled(need_disable); toolbar.btnSuperscript.setDisabled(need_disable);
@ -2974,6 +2977,23 @@ define([
this._state.lang = langId; this._state.lang = langId;
}, },
onInsDateTimeClick: function() {
//insert date time
var me = this;
(new DE.Views.DateTimeDialog({
api: this.api,
lang: this._state.lang,
handler: function(result, value) {
if (result == 'ok') {
if (me.api) {
// me.api.asc_addDateTime(value);
}
}
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}
})).show();
},
textEmptyImgUrl : 'You need to specify image URL.', textEmptyImgUrl : 'You need to specify image URL.',
textWarning : 'Warning', textWarning : 'Warning',
textFontSizeErr : 'The entered value is incorrect.<br>Please enter a numeric value between 1 and 100', textFontSizeErr : 'The entered value is incorrect.<br>Please enter a numeric value between 1 and 100',

View file

@ -83,7 +83,6 @@
<div class="group"> <div class="group">
<span class="btn-slot text x-huge" id="slot-btn-blankpage"></span> <span class="btn-slot text x-huge" id="slot-btn-blankpage"></span>
<span class="btn-slot text x-huge btn-pagebreak"></span> <span class="btn-slot text x-huge btn-pagebreak"></span>
<span class="btn-slot text x-huge" id="slot-btn-editheader"></span>
</div> </div>
<div class="separator long"></div> <div class="separator long"></div>
<div class="group"> <div class="group">
@ -97,8 +96,13 @@
</div> </div>
<div class="separator long"></div> <div class="separator long"></div>
<div class="group"> <div class="group">
<span class="btn-slot text x-huge slot-inshyperlink"></span>
<span class="btn-slot text x-huge slot-comment"></span> <span class="btn-slot text x-huge slot-comment"></span>
<span class="btn-slot text x-huge slot-inshyperlink"></span>
</div>
<div class="separator long"></div>
<div class="group">
<span class="btn-slot text x-huge" id="slot-btn-editheader"></span>
<span class="btn-slot text x-huge" id="slot-btn-datetime"></span>
</div> </div>
<div class="separator long"></div> <div class="separator long"></div>
<div class="group"> <div class="group">

View file

@ -0,0 +1,254 @@
/*
*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
/**
* DateTimeDialog.js
*
* Created by Julia Radzhabova on 26.06.2019
* Copyright (c) 2019 Ascensio System SIA. All rights reserved.
*
*/
define([
'common/main/lib/component/Window',
'common/main/lib/component/ComboBox',
'common/main/lib/component/ListView'
], function () {
'use strict';
DE.Views.DateTimeDialog = Common.UI.Window.extend(_.extend({
options: {
width: 350,
style: 'min-width: 230px;',
cls: 'modal-dlg',
buttons: ['ok', 'cancel']
},
initialize : function (options) {
var t = this,
_options = {};
_.extend(this.options, {
title: this.txtTitle
}, options || {});
this.template = [
'<div class="box" style="height: 275px;">',
'<div class="input-row">',
'<label style="font-weight: bold;">' + this.textLang + '</label>',
'</div>',
'<div id="datetime-dlg-lang" class="input-row" style="margin-bottom: 8px;"></div>',
'<div class="input-row">',
'<label style="font-weight: bold;">' + this.textFormat + '</label>',
'</div>',
'<div id="datetime-dlg-format" class="" style="margin-bottom: 10px;width: 100%; height: 165px; overflow: hidden;"></div>',
'<div class="input-row">',
'<div id="datetime-dlg-update" style="margin-top: 3px;"></div>',
'<button type="button" class="btn btn-text-default auto" id="datetime-dlg-default" style="float: right;">' + this.textDefault + '</button>',
'</div>',
'</div>'
].join('');
this.options.tpl = _.template(this.template)(this.options);
this.api = this.options.api;
this.lang = this.options.lang;
this.handler = this.options.handler;
Common.UI.Window.prototype.initialize.call(this, this.options);
},
render: function () {
Common.UI.Window.prototype.render.call(this);
var data = [{ value: 0x042C }, { value: 0x0402 }, { value: 0x0405 }, { value: 0x0407 }, {value: 0x0807}, { value: 0x0408 }, { value: 0x0C09 }, { value: 0x0809 }, { value: 0x0409 }, { value: 0x0C0A }, { value: 0x080A },
{ value: 0x040B }, { value: 0x040C }, { value: 0x0410 }, { value: 0x0411 }, { value: 0x0412 }, { value: 0x0426 }, { value: 0x0413 }, { value: 0x0415 }, { value: 0x0416 },
{ value: 0x0816 }, { value: 0x0419 }, { value: 0x041B }, { value: 0x0424 }, { value: 0x081D }, { value: 0x041D }, { value: 0x041F }, { value: 0x0422 }, { value: 0x042A }, { value: 0x0804 }];
data.forEach(function(item) {
var langinfo = Common.util.LanguageInfo.getLocalLanguageName(item.value);
item.displayValue = langinfo[1];
item.langName = langinfo[0];
});
this.cmbLang = new Common.UI.ComboBox({
el : $('#datetime-dlg-lang'),
menuStyle : 'min-width: 100%; max-height: 185px;',
cls : 'input-group-nr',
editable : false,
data : data
});
this.cmbLang.setValue(0x0409);
this.cmbLang.on('selected', _.bind(function(combo, record) {
this.updateFormats(record.value);
}, this));
this.chUpdate = new Common.UI.CheckBox({
el: $('#datetime-dlg-update'),
labelText: this.textUpdate
});
this.chUpdate.on('change', _.bind(function(field, newValue, oldValue, eOpts){
this.onSelectFormat(this.listFormats, null, this.listFormats.getSelectedRec());
}, this));
this.listFormats = new Common.UI.ListView({
el: $('#datetime-dlg-format'),
store: new Common.UI.DataViewStore(),
scrollAlwaysVisible: true
});
this.listFormats.on('item:select', _.bind(this.onSelectFormat, this));
this.listFormats.on('item:dblclick', _.bind(this.onDblClickFormat, this));
this.listFormats.on('entervalue', _.bind(this.onPrimary, this));
this.listFormats.$el.find('.listview').focus();
this.btnDefault = new Common.UI.Button({
el: $('#datetime-dlg-default')
});
this.btnDefault.on('click', _.bind(function(btn, e) {
var rec = this.listFormats.getSelectedRec();
Common.UI.warning({
msg: Common.Utils.String.format(this.confirmDefault, Common.util.LanguageInfo.getLocalLanguageName(this.cmbLang.getValue())[1], rec ? rec.get('value') : ''),
buttons: ['yes', 'no'],
primary: 'yes',
callback: _.bind(function(btn) {
if (btn == 'yes') {
this.defaultFormats[this.cmbLang.getValue()] = rec ? rec.get('format') : '';
this.api.asc_setDefaultDateTimeFormat(this.defaultFormats);
var arr = [];
for (var name in this.defaultFormats) {
if (name) {
arr.push(name + ' ' + this.defaultFormats[name]);
}
}
var value = arr.join(';');
Common.localStorage.setItem("de-settings-datetime-default", value);
Common.Utils.InternalSettings.set("de-settings-datetime-default", value);
}
}, this)
});
}, this));
this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.afterRender();
},
afterRender: function() {
var me = this,
value = Common.Utils.InternalSettings.get("de-settings-datetime-default"),
arr = (value) ? value.split(';') : [];
this.defaultFormats = [];
arr.forEach(function(item){
var pair = item.split(' ');
me.defaultFormats[parseInt(pair[0])] = pair[1];
});
this._setDefaults();
},
_setDefaults: function () {
// this.props = new AscCommonSlide.CAscDateTime();
if (this.lang) {
var item = this.cmbLang.store.findWhere({value: this.lang});
item = item ? item.get('value') : 0x0409;
this.cmbLang.setValue(item)
}
this.updateFormats(this.cmbLang.getValue());
},
getSettings: function () {
return this.props;
},
updateFormats: function(lang) {
return;
this.props.put_Lang(lang);
var data = this.props.get_DateTimeExamples(),
arr = [];
var store = this.listFormats.store;
for (var name in data) {
if (data[name]) {
var rec = new Common.UI.DataViewModel();
rec.set({
format: name,
value: data[name]
});
arr.push(rec);
}
}
store.reset(arr);
var format = this.defaultFormats[lang];
format ? this.listFormats.selectRecord(store.findWhere({format: format})) : this.listFormats.selectByIndex(0);
var rec = this.listFormats.getSelectedRec();
this.listFormats.scrollToRecord(rec);
this.onSelectFormat(this.listFormats, null, rec);
},
onSelectFormat: function(lisvView, itemView, record) {
return;
if (!record) return;
if (this.chUpdate.getValue()=='checked') {
this.props.put_DateTime(record.get('format'));
} else {
this.props.put_DateTime(null);
this.props.put_CustomDateTime(record.get('value'));
}
},
onBtnClick: function(event) {
this._handleInput(event.currentTarget.attributes['result'].value);
},
onDblClickFormat: function () {
this._handleInput('ok');
},
onPrimary: function(event) {
this._handleInput('ok');
return false;
},
_handleInput: function(state) {
if (this.options.handler) {
this.options.handler.call(this, state, this.getSettings());
}
this.close();
},
//
txtTitle: 'Date & Time',
textLang: 'Language',
textFormat: 'Formats',
textUpdate: 'Update automatically',
textDefault: 'Set as default',
confirmDefault: 'Set default format for {0}: "{1}"'
}, DE.Views.DateTimeDialog || {}));
});

View file

@ -515,6 +515,14 @@ define([
this.paragraphControls.push(this.mnuInsertPageCount); this.paragraphControls.push(this.mnuInsertPageCount);
this.toolbarControls.push(this.btnEditHeader); this.toolbarControls.push(this.btnEditHeader);
this.btnInsDateTime = new Common.UI.Button({
id: 'id-toolbar-btn-datetime',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-datetime',
caption: me.capBtnDateTime
});
this.paragraphControls.push(this.btnInsDateTime);
this.btnBlankPage = new Common.UI.Button({ this.btnBlankPage = new Common.UI.Button({
id: 'id-toolbar-btn-blankpage', id: 'id-toolbar-btn-blankpage',
cls: 'btn-toolbar x-huge icon-top', cls: 'btn-toolbar x-huge icon-top',
@ -1309,6 +1317,7 @@ define([
_injectComponent('#slot-btn-controls', this.btnContentControls); _injectComponent('#slot-btn-controls', this.btnContentControls);
_injectComponent('#slot-btn-columns', this.btnColumns); _injectComponent('#slot-btn-columns', this.btnColumns);
_injectComponent('#slot-btn-editheader', this.btnEditHeader); _injectComponent('#slot-btn-editheader', this.btnEditHeader);
_injectComponent('#slot-btn-datetime', this.btnInsDateTime);
_injectComponent('#slot-btn-blankpage', this.btnBlankPage); _injectComponent('#slot-btn-blankpage', this.btnBlankPage);
_injectComponent('#slot-btn-insshape', this.btnInsertShape); _injectComponent('#slot-btn-insshape', this.btnInsertShape);
_injectComponent('#slot-btn-insequation', this.btnInsertEquation); _injectComponent('#slot-btn-insequation', this.btnInsertEquation);
@ -1585,6 +1594,7 @@ define([
this.btnInsertText.updateHint(this.tipInsertText); this.btnInsertText.updateHint(this.tipInsertText);
this.btnInsertTextArt.updateHint(this.tipInsertTextArt); this.btnInsertTextArt.updateHint(this.tipInsertTextArt);
this.btnEditHeader.updateHint(this.tipEditHeader); this.btnEditHeader.updateHint(this.tipEditHeader);
this.btnInsDateTime.updateHint(this.tipDateTime);
this.btnBlankPage.updateHint(this.tipBlankPage); this.btnBlankPage.updateHint(this.tipBlankPage);
this.btnInsertShape.updateHint(this.tipInsertShape); this.btnInsertShape.updateHint(this.tipInsertShape);
this.btnInsertEquation.updateHint(this.tipInsertEquation); this.btnInsertEquation.updateHint(this.tipInsertEquation);
@ -2289,7 +2299,9 @@ define([
capBtnInsSymbol: 'Symbol', capBtnInsSymbol: 'Symbol',
tipInsertSymbol: 'Insert symbol', tipInsertSymbol: 'Insert symbol',
mniDrawTable: 'Draw Table', mniDrawTable: 'Draw Table',
mniEraseTable: 'Erase Table' mniEraseTable: 'Erase Table',
capBtnDateTime: 'Date & Time',
tipDateTime: 'Insert current date and time'
} }
})(), DE.Views.Toolbar || {})); })(), DE.Views.Toolbar || {}));
}); });

View file

@ -1166,6 +1166,12 @@
"DE.Views.CustomColumnsDialog.textSeparator": "Column divider", "DE.Views.CustomColumnsDialog.textSeparator": "Column divider",
"DE.Views.CustomColumnsDialog.textSpacing": "Spacing between columns", "DE.Views.CustomColumnsDialog.textSpacing": "Spacing between columns",
"DE.Views.CustomColumnsDialog.textTitle": "Columns", "DE.Views.CustomColumnsDialog.textTitle": "Columns",
"DE.Views.DateTimeDialog.confirmDefault": "Set default format for {0}: \"{1}\"",
"DE.Views.DateTimeDialog.textDefault": "Set as default",
"DE.Views.DateTimeDialog.textFormat": "Formats",
"DE.Views.DateTimeDialog.textLang": "Language",
"DE.Views.DateTimeDialog.textUpdate": "Update automatically",
"DE.Views.DateTimeDialog.txtTitle": "Date & Time",
"DE.Views.DocumentHolder.aboveText": "Above", "DE.Views.DocumentHolder.aboveText": "Above",
"DE.Views.DocumentHolder.addCommentText": "Add Comment", "DE.Views.DocumentHolder.addCommentText": "Add Comment",
"DE.Views.DocumentHolder.advancedFrameText": "Frame Advanced Settings", "DE.Views.DocumentHolder.advancedFrameText": "Frame Advanced Settings",
@ -2339,6 +2345,8 @@
"DE.Views.Toolbar.textDateControl": "Date", "DE.Views.Toolbar.textDateControl": "Date",
"DE.Views.Toolbar.mniDrawTable": "Draw Table", "DE.Views.Toolbar.mniDrawTable": "Draw Table",
"DE.Views.Toolbar.mniEraseTable": "Erase Table", "DE.Views.Toolbar.mniEraseTable": "Erase Table",
"DE.Views.Toolbar.capBtnDateTime": "Date & Time",
"DE.Views.Toolbar.tipDateTime": "Insert current date and time",
"DE.Views.WatermarkSettingsDialog.textAuto": "Auto", "DE.Views.WatermarkSettingsDialog.textAuto": "Auto",
"DE.Views.WatermarkSettingsDialog.textBold": "Bold", "DE.Views.WatermarkSettingsDialog.textBold": "Bold",
"DE.Views.WatermarkSettingsDialog.textColor": "Text color", "DE.Views.WatermarkSettingsDialog.textColor": "Text color",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 772 B