Commit a362235a authored by Julia Radzhabova's avatar Julia Radzhabova

Rename file from editors.

parent e0575a4d
......@@ -232,6 +232,14 @@ Common.Gateway = new(function() {
collaborativeChanges: function() {
_postMessage({event: 'onCollaborativeChanges'});
},
requestRename: function(title) {
_postMessage({event: 'onRequestRename', data: title});
},
metaChange: function(meta) {
_postMessage({event: 'onMetaChange', data: meta});
},
on: function(event, handler){
var localHandler = function(event, data){
......
......@@ -2,6 +2,6 @@
<div id="header-logo"></div>
<div id="header-caption"><div><%= headerCaption %></div></div>
<div id="header-developer" class="hidden"><div><%= headerDeveloper %></div></div>
<div id="header-documentcaption"><%= documentCaption %></div>
<div id="header-documentcaption"><span><%= documentCaption %></span></div>
<div id="header-back" style="display: <%= canBack ? 'table-cell' : 'none' %>;"><div><%= textBack %></div></div>
</div>
\ No newline at end of file
......@@ -46,7 +46,8 @@ Common.Views = Common.Views || {};
define([
'backbone',
'text!common/main/lib/template/Header.template',
'core'
'core',
'common/main/lib/view/RenameDialog'
], function (Backbone, headerTemplate) { 'use strict';
Common.Views.Header = Backbone.View.extend(_.extend({
......@@ -165,7 +166,7 @@ define([
if (!value)
value = '';
var dc = $('#header-documentcaption');
var dc = $('#header-documentcaption span');
if (dc)
dc.html(Common.Utils.String.htmlEncode(value));
......@@ -226,8 +227,36 @@ define([
$('#header-developer').toggleClass('hidden', !mode);
},
setCanRename: function(rename) {
var dc = $('#header-documentcaption span');
if (rename) {
var me = this;
dc.tooltip({title: me.txtRename, placement: 'cursor'});
dc.on('click', function(e) {
(new Common.Views.RenameDialog({
filename: me.documentCaption,
handler: function(result, value) {
if (result == 'ok' && !_.isEmpty(value.trim()) && me.documentCaption !== value.trim()) {
Common.Gateway.requestRename(value);
}
Common.NotificationCenter.trigger('edit:complete', me);
}
})).show(dc.position().left-1, 20);
});
} else {
var tip = dc.data('bs.tooltip');
if (tip) {
tip.options.title = '';
tip.setContent();
}
dc.off('click');
}
dc.css('cursor', rename ? 'pointer' : 'default');
},
textBack: 'Go to Documents',
openNewTabText: 'Open in New Tab',
txtHeaderDeveloper: 'DEVELOPER MODE'
txtHeaderDeveloper: 'DEVELOPER MODE',
txtRename: 'Rename'
}, Common.Views.Header || {}))
});
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
/**
* RenameDialog.js
*
* Created by Julia Radzhabova on 9/23/16
* Copyright (c) 2014 Ascensio System SIA. All rights reserved.
*
*/
define([
'common/main/lib/component/Window'
], function () { 'use strict';
Common.Views.RenameDialog = Common.UI.Window.extend(_.extend({
options: {
width: 330,
header: false,
cls: 'modal-dlg',
filename: ''
},
initialize : function(options) {
_.extend(this.options, options || {});
this.template = [
'<div class="box">',
'<div class="input-row">',
'<label>' + this.textName + '</label>',
'</div>',
'<div id="id-dlg-newname" class="input-row"></div>',
'</div>',
'<div class="footer right">',
'<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">' + this.okButtonText + '</button>',
'<button class="btn normal dlg-btn" result="cancel">' + this.cancelButtonText + '</button>',
'</div>'
].join('');
this.options.tpl = _.template(this.template, this.options);
Common.UI.Window.prototype.initialize.call(this, this.options);
},
render: function() {
Common.UI.Window.prototype.render.call(this);
var me = this;
me.inputName = new Common.UI.InputField({
el : $('#id-dlg-newname'),
style : 'width: 100%;',
validateOnBlur: false,
validation : function(value) {
return (/[\t*\+:\"<>?|\\\\/]/gim.test(value)) ? me.txtInvalidName + "*+:\"<>?|\/" : true;
}
});
var $window = this.getChild();
$window.find('.btn').on('click', _.bind(this.onBtnClick, this));
me.inputNameEl = $window.find('input');
me.inputNameEl.on('keypress', _.bind(this.onKeyPress, this));
},
show: function() {
Common.UI.Window.prototype.show.apply(this, arguments);
var me = this;
_.delay(function(){
me.inputName.setValue(me.options.filename);
me.inputNameEl.focus().select();
},100);
},
onKeyPress: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) {
this._handleInput('ok');
}
},
onBtnClick: function(event) {
this._handleInput(event.currentTarget.attributes['result'].value);
},
_handleInput: function(state) {
if (this.options.handler) {
if (state == 'ok') {
if (this.inputName.checkValidate() !== true) {
this.inputNameEl.focus();
return;
}
}
this.options.handler.call(this, state, this.inputName.getValue());
}
this.close();
},
textName : 'File name',
cancelButtonText: 'Cancel',
okButtonText : 'Ok',
txtInvalidName : 'The file name cannot contain any of the following characters: '
}, Common.Views.RenameDialog || {}));
});
\ No newline at end of file
......@@ -130,6 +130,7 @@ define([
this.api.asc_registerCallback('asc_onAdvancedOptions', _.bind(this.onAdvancedOptions, this));
this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this));
this.api.asc_registerCallback('asc_onPrintUrl', _.bind(this.onPrintUrl, this));
this.api.asc_registerCallback('asc_onMeta', _.bind(this.onMeta, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('goback', _.bind(this.goBack, this));
......@@ -363,6 +364,7 @@ define([
});
} else {
this.api.asc_coAuthoringDisconnect();
this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false);
this.getApplication().getController('LeftMenu').getView('LeftMenu').showHistory();
this.disableEditing(true);
var versions = opts.data.history,
......@@ -976,11 +978,13 @@ define([
this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view';
var headerView = this.getApplication().getController('Viewport').getView('Common.Views.Header');
this.appOptions.canBranding = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object');
if (this.appOptions.canBranding)
this.getApplication().getController('Viewport').getView('Common.Views.Header').setBranding(this.editorConfig.customization);
headerView.setBranding(this.editorConfig.customization);
params.asc_getTrial() && this.getApplication().getController('Viewport').getView('Common.Views.Header').setDeveloperMode(true);
params.asc_getTrial() && headerView.setDeveloperMode(true);
this.permissions.rename && headerView.setCanRename(true);
this.applyModeCommonElements();
this.applyModeEditorElements();
......@@ -1276,6 +1280,7 @@ define([
onCoAuthoringDisconnect: function() {
this.getApplication().getController('Viewport').getView('Viewport').setMode({isDisconnected:true});
this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false);
this._state.isDisconnected = true;
},
......@@ -1706,6 +1711,17 @@ define([
this.updateWindowTitle(true);
},
onMeta: function(meta) {
var app = this.getApplication(),
filemenu = app.getController('LeftMenu').getView('LeftMenu').getMenu('file');
app.getController('Viewport').getView('Common.Views.Header').setDocumentCaption(meta.title);
this.updateWindowTitle(true);
this.document.title = meta.title;
filemenu.loadDocument({doc:this.document});
filemenu.panels['info'].updateInfo(this.document);
Common.Gateway.metaChange(meta);
},
onPrint: function() {
if (!this.appOptions.canPrint) return;
......
......@@ -142,6 +142,7 @@
"Common.Views.Header.openNewTabText": "Open in New Tab",
"Common.Views.Header.textBack": "Go to Documents",
"Common.Views.Header.txtHeaderDeveloper": "DEVELOPER MODE",
"Common.Views.Header.txtRename": "Rename",
"Common.Views.History.textHistoryHeader": "Back to Document",
"Common.Views.History.textRestore": "Restore",
"Common.Views.ImageFromUrlDialog.cancelButtonText": "Cancel",
......@@ -167,6 +168,10 @@
"Common.Views.Plugins.strPlugins": "Plugins",
"Common.Views.Plugins.textLoading": "Loading",
"Common.Views.Plugins.textStart": "Start",
"Common.Views.RenameDialog.cancelButtonText": "Cancel",
"Common.Views.RenameDialog.okButtonText": "Ok",
"Common.Views.RenameDialog.textName": "File name",
"Common.Views.RenameDialog.txtInvalidName": "The file name cannot contain any of the following characters: ",
"Common.Views.ReviewChanges.txtAccept": "Accept",
"Common.Views.ReviewChanges.txtAcceptAll": "Accept All Changes",
"Common.Views.ReviewChanges.txtAcceptCurrent": "Accept Current Change",
......
......@@ -121,6 +121,7 @@ define([
this.api.asc_registerCallback('asc_onDocumentUpdateVersion', _.bind(this.onUpdateVersion, this));
this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this));
this.api.asc_registerCallback('asc_onPrintUrl', _.bind(this.onPrintUrl, this));
this.api.asc_registerCallback('asc_onMeta', _.bind(this.onMeta, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('goback', _.bind(this.goBack, this));
......@@ -741,11 +742,13 @@ define([
this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view';
var headerView = this.getApplication().getController('Viewport').getView('Common.Views.Header');
this.appOptions.canBranding = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object');
if (this.appOptions.canBranding)
this.getApplication().getController('Viewport').getView('Common.Views.Header').setBranding(this.editorConfig.customization);
headerView.setBranding(this.editorConfig.customization);
params.asc_getTrial() && this.getApplication().getController('Viewport').getView('Common.Views.Header').setDeveloperMode(true);
params.asc_getTrial() && headerView.setDeveloperMode(true);
this.permissions.rename && headerView.setCanRename(true);
this.applyModeCommonElements();
this.applyModeEditorElements();
......@@ -1030,6 +1033,7 @@ define([
onCoAuthoringDisconnect: function() {
// TODO: Disable all except 'Download As' and 'Print'
this.getApplication().getController('Viewport').getView('Viewport').setMode({isDisconnected:true});
this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false);
this._state.isDisconnected = true;
// this.getFileMenu().setMode({isDisconnected:true});
},
......@@ -1464,6 +1468,17 @@ define([
this.updateWindowTitle(true);
},
onMeta: function(meta) {
var app = this.getApplication(),
filemenu = app.getController('LeftMenu').getView('LeftMenu').getMenu('file');
app.getController('Viewport').getView('Common.Views.Header').setDocumentCaption(meta.title);
this.updateWindowTitle(true);
this.document.title = meta.title;
filemenu.loadDocument({doc:this.document});
filemenu.panels['info'].updateInfo(this.document);
Common.Gateway.metaChange(meta);
},
onPrint: function() {
if (!this.appOptions.canPrint) return;
......
......@@ -81,6 +81,7 @@
"Common.Views.Header.openNewTabText": "Open in New Tab",
"Common.Views.Header.textBack": "Go to Documents",
"Common.Views.Header.txtHeaderDeveloper": "DEVELOPER MODE",
"Common.Views.Header.txtRename": "Rename",
"Common.Views.ImageFromUrlDialog.cancelButtonText": "Cancel",
"Common.Views.ImageFromUrlDialog.okButtonText": "OK",
"Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:",
......@@ -98,14 +99,16 @@
"Common.Views.Plugins.strPlugins": "Plugins",
"Common.Views.Plugins.textLoading": "Loading",
"Common.Views.Plugins.textStart": "Start",
"Common.Views.RenameDialog.cancelButtonText": "Cancel",
"Common.Views.RenameDialog.okButtonText": "Ok",
"Common.Views.RenameDialog.textName": "File name",
"Common.Views.RenameDialog.txtInvalidName": "The file name cannot contain any of the following characters: ",
"PE.Controllers.LeftMenu.newDocumentTitle": "Unnamed presentation",
"PE.Controllers.LeftMenu.requestEditRightsText": "Requesting editing rights...",
"PE.Controllers.LeftMenu.textNoTextFound": "The data you have been searching for could not be found. Please adjust your search options.",
"PE.Controllers.Main.applyChangesTextText": "Loading data...",
"PE.Controllers.Main.applyChangesTitleText": "Loading Data",
"del_PE.Controllers.Main.convertationErrorText": "Conversion failed.",
"PE.Controllers.Main.openErrorText": "An error has occurred while opening the file",
"PE.Controllers.Main.saveErrorText": "An error has occurred while saving the file",
"PE.Controllers.Main.convertationTimeoutText": "Conversion timeout exceeded.",
"PE.Controllers.Main.criticalErrorExtText": "Press \"OK\" to return to document list.",
"PE.Controllers.Main.criticalErrorTitle": "Error",
......
......@@ -121,6 +121,7 @@ define([
this.api.asc_registerCallback('asc_onDocumentUpdateVersion', _.bind(this.onUpdateVersion, this));
this.api.asc_registerCallback('asc_onDocumentName', _.bind(this.onDocumentName, this));
this.api.asc_registerCallback('asc_onPrintUrl', _.bind(this.onPrintUrl, this));
this.api.asc_registerCallback('asc_onMeta', _.bind(this.onMeta, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('goback', _.bind(this.goBack, this));
Common.NotificationCenter.on('namedrange:locked', _.bind(this.onNamedRangeLocked, this));
......@@ -764,6 +765,7 @@ define([
this.headerView.setBranding(this.editorConfig.customization);
params.asc_getTrial() && this.headerView.setDeveloperMode(true);
this.permissions.rename && this.headerView.setCanRename(true);
}
this.appOptions.canRequestEditRights = this.editorConfig.canRequestEditRights;
......@@ -1183,7 +1185,8 @@ define([
onCoAuthoringDisconnect: function() {
this.getApplication().getController('Viewport').getView('Viewport').setMode({isDisconnected:true});
this._state.isDisconnected = true;
this.getApplication().getController('Viewport').getView('Common.Views.Header').setCanRename(false);
this._state.isDisconnected = true;
},
showTips: function(strings) {
......@@ -1699,6 +1702,17 @@ define([
this.updateWindowTitle(this.api.asc_isDocumentModified(), true);
},
onMeta: function(meta) {
var app = this.getApplication(),
filemenu = app.getController('LeftMenu').getView('LeftMenu').getMenu('file');
app.getController('Viewport').getView('Common.Views.Header').setDocumentCaption(meta.title);
this.updateWindowTitle(true);
this.appOptions.spreadsheet.title = meta.title;
filemenu.loadDocument({doc:this.appOptions.spreadsheet});
filemenu.panels['info'].updateInfo(this.appOptions.spreadsheet);
Common.Gateway.metaChange(meta);
},
onPrint: function() {
if (!this.appOptions.canPrint) return;
Common.NotificationCenter.trigger('print', this);
......
......@@ -75,6 +75,7 @@
"Common.Views.Header.openNewTabText": "Open in New Tab",
"Common.Views.Header.textBack": "Go to Documents",
"Common.Views.Header.txtHeaderDeveloper": "DEVELOPER MODE",
"Common.Views.Header.txtRename": "Rename",
"Common.Views.ImageFromUrlDialog.cancelButtonText": "Cancel",
"Common.Views.ImageFromUrlDialog.okButtonText": "OK",
"Common.Views.ImageFromUrlDialog.textUrl": "Paste an image URL:",
......@@ -93,6 +94,10 @@
"Common.Views.Plugins.strPlugins": "Plugins",
"Common.Views.Plugins.textLoading": "Loading",
"Common.Views.Plugins.textStart": "Start",
"Common.Views.RenameDialog.cancelButtonText": "Cancel",
"Common.Views.RenameDialog.okButtonText": "Ok",
"Common.Views.RenameDialog.textName": "File name",
"Common.Views.RenameDialog.txtInvalidName": "The file name cannot contain any of the following characters: ",
"SSE.Controllers.DocumentHolder.errorInvalidLink": "The link reference does not exist. Please correct the link or delete it.",
"SSE.Controllers.DocumentHolder.guestText": "Guest",
"SSE.Controllers.DocumentHolder.notcriticalErrorTitle": "Warning",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment