Refactoring create new file: show "create new" when templates are available in config
This commit is contained in:
parent
2b81097012
commit
704c5a6a00
|
@ -373,7 +373,7 @@ define([
|
||||||
this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id);
|
this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id);
|
||||||
|
|
||||||
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
|
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
|
||||||
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
|
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl) || this.editorConfig.templates && this.editorConfig.templates.length;
|
||||||
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
|
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
|
||||||
this.appOptions.templates = this.editorConfig.templates;
|
this.appOptions.templates = this.editorConfig.templates;
|
||||||
this.appOptions.recent = this.editorConfig.recent;
|
this.appOptions.recent = this.editorConfig.recent;
|
||||||
|
|
|
@ -389,7 +389,7 @@ define([
|
||||||
if ( this.mode.canCreateNew ) {
|
if ( this.mode.canCreateNew ) {
|
||||||
if (this.mode.templates && this.mode.templates.length) {
|
if (this.mode.templates && this.mode.templates.length) {
|
||||||
$('a',this.miNew.$el).text(this.btnCreateNewCaption + '...');
|
$('a',this.miNew.$el).text(this.btnCreateNewCaption + '...');
|
||||||
!this.panels['new'] && (this.panels['new'] = ((new DE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates})).render()));
|
!this.panels['new'] && (this.panels['new'] = ((new DE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates, blank: this.mode.canRequestCreateNew || !!this.mode.createUrl})).render()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -869,21 +869,23 @@ define([
|
||||||
template: _.template([
|
template: _.template([
|
||||||
'<h3 style="margin-top: 20px;"><%= scope.txtCreateNew %></h3>',
|
'<h3 style="margin-top: 20px;"><%= scope.txtCreateNew %></h3>',
|
||||||
'<div class="thumb-list">',
|
'<div class="thumb-list">',
|
||||||
|
'<% if (blank) { %> ',
|
||||||
'<div class="blank-document">',
|
'<div class="blank-document">',
|
||||||
'<div class="blank-document-btn">',
|
'<div class="blank-document-btn">',
|
||||||
'<svg class="btn-blank-format"><use xlink:href="#svg-format-blank"></use></svg>',
|
'<svg class="btn-blank-format"><use xlink:href="#svg-format-blank"></use></svg>',
|
||||||
'</div>',
|
'</div>',
|
||||||
'<div class="title"><%= scope.txtBlank %></div>',
|
'<div class="title"><%= scope.txtBlank %></div>',
|
||||||
'</div>',
|
'</div>',
|
||||||
'<% _.each(docs, function(item, index) { %>',
|
'<% } %>',
|
||||||
'<div class="thumb-wrap" template="<%= item.url %>">',
|
'<% _.each(docs, function(item, index) { %>',
|
||||||
'<div class="thumb" ',
|
'<div class="thumb-wrap" template="<%= item.url %>">',
|
||||||
'<% if (!_.isEmpty(item.image)) {%> ',
|
'<div class="thumb" ',
|
||||||
' style="background-image: url(<%= item.image %>);">',
|
'<% if (!_.isEmpty(item.image)) {%> ',
|
||||||
' <%} else {' +
|
' style="background-image: url(<%= item.image %>);">',
|
||||||
'print(\"><svg class=\'btn-blank-format\'><use xlink:href=\'#svg-file-template\'></use></svg>\")' +
|
' <%} else {' +
|
||||||
' } %>',
|
'print(\"><svg class=\'btn-blank-format\'><use xlink:href=\'#svg-file-template\'></use></svg>\")' +
|
||||||
'</div>',
|
' } %>',
|
||||||
|
'</div>',
|
||||||
'<div class="title"><%= Common.Utils.String.htmlEncode(item.title || item.name || "") %></div>',
|
'<div class="title"><%= Common.Utils.String.htmlEncode(item.title || item.name || "") %></div>',
|
||||||
'</div>',
|
'</div>',
|
||||||
'<% }) %>',
|
'<% }) %>',
|
||||||
|
@ -894,14 +896,17 @@ define([
|
||||||
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
||||||
|
|
||||||
this.menu = options.menu;
|
this.menu = options.menu;
|
||||||
|
this.docs = options.docs;
|
||||||
|
this.blank = !!options.blank;
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
this.$el.html(this.template({
|
this.$el.html(this.template({
|
||||||
scope: this,
|
scope: this,
|
||||||
docs: this.options[0].docs
|
docs: this.docs,
|
||||||
|
blank: this.blank
|
||||||
}));
|
}));
|
||||||
var docs=[{title: this.txtBlank}].concat(this.options[0].docs);
|
var docs = (this.blank ? [{title: this.txtBlank}] : []).concat(this.docs);
|
||||||
var thumbsElm= this.$el.find('.thumb-wrap, .blank-document');
|
var thumbsElm= this.$el.find('.thumb-wrap, .blank-document');
|
||||||
_.each(thumbsElm, function (tmb, index){
|
_.each(thumbsElm, function (tmb, index){
|
||||||
$(tmb).find('.title').tooltip({
|
$(tmb).find('.title').tooltip({
|
||||||
|
|
|
@ -333,7 +333,7 @@ define([
|
||||||
this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id);
|
this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id);
|
||||||
|
|
||||||
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
|
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
|
||||||
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
|
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl) || this.editorConfig.templates && this.editorConfig.templates.length;
|
||||||
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
|
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
|
||||||
this.appOptions.templates = this.editorConfig.templates;
|
this.appOptions.templates = this.editorConfig.templates;
|
||||||
this.appOptions.recent = this.editorConfig.recent;
|
this.appOptions.recent = this.editorConfig.recent;
|
||||||
|
|
|
@ -388,7 +388,7 @@ define([
|
||||||
if ( this.mode.canCreateNew ) {
|
if ( this.mode.canCreateNew ) {
|
||||||
if (this.mode.templates && this.mode.templates.length) {
|
if (this.mode.templates && this.mode.templates.length) {
|
||||||
$('a',this.miNew.$el).text(this.btnCreateNewCaption + '...');
|
$('a',this.miNew.$el).text(this.btnCreateNewCaption + '...');
|
||||||
!this.panels['new'] && (this.panels['new'] = (new PE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates})).render());
|
!this.panels['new'] && (this.panels['new'] = (new PE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates, blank: this.mode.canRequestCreateNew || !!this.mode.createUrl})).render());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -767,12 +767,14 @@ define([
|
||||||
template: _.template([
|
template: _.template([
|
||||||
'<h3 style="margin-top: 20px;"><%= scope.txtCreateNew %></h3>',
|
'<h3 style="margin-top: 20px;"><%= scope.txtCreateNew %></h3>',
|
||||||
'<div class="thumb-list">',
|
'<div class="thumb-list">',
|
||||||
|
'<% if (blank) { %> ',
|
||||||
'<div class="blank-document">',
|
'<div class="blank-document">',
|
||||||
'<div class="blank-document-btn">',
|
'<div class="blank-document-btn">',
|
||||||
'<svg class="btn-blank-format"><use xlink:href="#svg-format-blank"></use></svg>',
|
'<svg class="btn-blank-format"><use xlink:href="#svg-format-blank"></use></svg>',
|
||||||
'</div>',
|
'</div>',
|
||||||
'<div class="title"><%= scope.txtBlank %></div>',
|
'<div class="title"><%= scope.txtBlank %></div>',
|
||||||
'</div>',
|
'</div>',
|
||||||
|
'<% } %>',
|
||||||
'<% _.each(docs, function(item, index) { %>',
|
'<% _.each(docs, function(item, index) { %>',
|
||||||
'<div class="thumb-wrap" template="<%= item.url %>">',
|
'<div class="thumb-wrap" template="<%= item.url %>">',
|
||||||
'<div class="thumb" ',
|
'<div class="thumb" ',
|
||||||
|
@ -792,14 +794,17 @@ define([
|
||||||
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
||||||
|
|
||||||
this.menu = options.menu;
|
this.menu = options.menu;
|
||||||
|
this.docs = options.docs;
|
||||||
|
this.blank = !!options.blank;
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
this.$el.html(this.template({
|
this.$el.html(this.template({
|
||||||
scope: this,
|
scope: this,
|
||||||
docs: this.options[0].docs
|
docs: this.docs,
|
||||||
|
blank: this.blank
|
||||||
}));
|
}));
|
||||||
var docs=[{title: this.txtBlank}].concat(this.options[0].docs);
|
var docs = (this.blank ? [{title: this.txtBlank}] : []).concat(this.docs);
|
||||||
var thumbsElm= this.$el.find('.thumb-wrap, .blank-document');
|
var thumbsElm= this.$el.find('.thumb-wrap, .blank-document');
|
||||||
_.each(thumbsElm, function (tmb, index){
|
_.each(thumbsElm, function (tmb, index){
|
||||||
$(tmb).find('.title').tooltip({
|
$(tmb).find('.title').tooltip({
|
||||||
|
|
|
@ -372,7 +372,7 @@ define([
|
||||||
this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id);
|
this.appOptions.user.anonymous && Common.localStorage.setItem("guest-id", this.appOptions.user.id);
|
||||||
|
|
||||||
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
|
this.appOptions.isDesktopApp = this.editorConfig.targetApp == 'desktop';
|
||||||
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl);
|
this.appOptions.canCreateNew = this.editorConfig.canRequestCreateNew || !_.isEmpty(this.editorConfig.createUrl) || this.editorConfig.templates && this.editorConfig.templates.length;
|
||||||
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
|
this.appOptions.canOpenRecent = this.editorConfig.recent !== undefined && !this.appOptions.isDesktopApp;
|
||||||
this.appOptions.templates = this.editorConfig.templates;
|
this.appOptions.templates = this.editorConfig.templates;
|
||||||
this.appOptions.recent = this.editorConfig.recent;
|
this.appOptions.recent = this.editorConfig.recent;
|
||||||
|
|
|
@ -374,7 +374,7 @@ define([
|
||||||
if ( this.mode.canCreateNew ) {
|
if ( this.mode.canCreateNew ) {
|
||||||
if (this.mode.templates && this.mode.templates.length) {
|
if (this.mode.templates && this.mode.templates.length) {
|
||||||
$('a',this.miNew.$el).text(this.btnCreateNewCaption + '...');
|
$('a',this.miNew.$el).text(this.btnCreateNewCaption + '...');
|
||||||
!this.panels['new'] && (this.panels['new'] = (new SSE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates})).render());
|
!this.panels['new'] && (this.panels['new'] = (new SSE.Views.FileMenuPanels.CreateNew({menu: this, docs: this.mode.templates, blank: this.mode.canRequestCreateNew || !!this.mode.createUrl})).render());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1734,12 +1734,14 @@ define([
|
||||||
template: _.template([
|
template: _.template([
|
||||||
'<h3 style="margin-top: 20px;"><%= scope.txtCreateNew %></h3>',
|
'<h3 style="margin-top: 20px;"><%= scope.txtCreateNew %></h3>',
|
||||||
'<div class="thumb-list">',
|
'<div class="thumb-list">',
|
||||||
|
'<% if (blank) { %> ',
|
||||||
'<div class="blank-document">',
|
'<div class="blank-document">',
|
||||||
'<div class="blank-document-btn">',
|
'<div class="blank-document-btn">',
|
||||||
'<svg class="btn-blank-format"><use xlink:href="#svg-format-blank"></use></svg>',
|
'<svg class="btn-blank-format"><use xlink:href="#svg-format-blank"></use></svg>',
|
||||||
'</div>',
|
'</div>',
|
||||||
'<div class="title"><%= scope.txtBlank %></div>',
|
'<div class="title"><%= scope.txtBlank %></div>',
|
||||||
'</div>',
|
'</div>',
|
||||||
|
'<% } %>',
|
||||||
'<% _.each(docs, function(item, index) { %>',
|
'<% _.each(docs, function(item, index) { %>',
|
||||||
'<div class="thumb-wrap" template="<%= item.url %>">',
|
'<div class="thumb-wrap" template="<%= item.url %>">',
|
||||||
'<div class="thumb" ',
|
'<div class="thumb" ',
|
||||||
|
@ -1759,14 +1761,17 @@ define([
|
||||||
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
Common.UI.BaseView.prototype.initialize.call(this,arguments);
|
||||||
|
|
||||||
this.menu = options.menu;
|
this.menu = options.menu;
|
||||||
|
this.docs = options.docs;
|
||||||
|
this.blank = !!options.blank;
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
this.$el.html(this.template({
|
this.$el.html(this.template({
|
||||||
scope: this,
|
scope: this,
|
||||||
docs: this.options[0].docs
|
docs: this.docs,
|
||||||
|
blank: this.blank
|
||||||
}));
|
}));
|
||||||
var docs=[{title: this.txtBlank}].concat(this.options[0].docs);
|
var docs = (this.blank ? [{title: this.txtBlank}] : []).concat(this.docs);
|
||||||
var thumbsElm= this.$el.find('.thumb-wrap, .blank-document');
|
var thumbsElm= this.$el.find('.thumb-wrap, .blank-document');
|
||||||
_.each(thumbsElm, function (tmb, index){
|
_.each(thumbsElm, function (tmb, index){
|
||||||
$(tmb).find('.title').tooltip({
|
$(tmb).find('.title').tooltip({
|
||||||
|
|
Loading…
Reference in a new issue