fix #11: disallow groups without a title

This commit is contained in:
Antelle 2015-11-04 08:29:28 +03:00
parent 3b0c0f9f89
commit c40d516b6d
5 changed files with 8 additions and 3 deletions

View File

@ -94,6 +94,7 @@ var GroupModel = MenuItemModel.extend({
removeGroup: function(group) {
this.get('items').remove(group);
this.trigger('remove', group);
},
addGroup: function(group) {
@ -132,6 +133,7 @@ var GroupModel = MenuItemModel.extend({
this.parentGroup.group.groups.splice(ix, 1);
}
this.parentGroup.removeGroup(this);
this.trigger('delete');
}
});

View File

@ -26,6 +26,9 @@ var GrpView = Backbone.View.extend({
icon: this.model.get('icon') || 'folder',
readonly: this.model.get('top')
}));
if (!this.model.get('title')) {
this.$el.find('#grp__field-title').focus();
}
}
this.scroll = baron({
root: this.$el.find('.details__body')[0],

View File

@ -75,7 +75,7 @@ var MenuItemView = Backbone.View.extend({
},
changeTitle: function(model, title) {
this.$el.find('.menu__item-title').first().text(title);
this.$el.find('.menu__item-title').first().text(title || '(no title)');
},
changeIcon: function(model, icon) {

View File

@ -4,7 +4,7 @@
<div class="grp__field">
<label for="grp__field-title">Name:</label>
<input type="text" class="input-base" id="grp__field-title" value="<%- title %>" size="50" maxlength="1024"
required <%= readonly ? 'readonly' : '' %> <%= title ? '' : 'autofocus' %> />
required <%= readonly ? 'readonly' : '' %> />
</div>
<label>Icon:</label>
<i class="fa fa-<%- icon %> grp__icon"></i>

View File

@ -5,7 +5,7 @@
cls ? cls : '' %>">
<div class="menu__item-body">
<i class="menu__item-icon fa <%= icon ? 'fa-' + icon : 'menu__item-icon--no-icon' %>"></i><span
class="menu__item-title"><%- title %></span>
class="menu__item-title"><%- title || '(no title)' %></span>
<% if (options) { %>
<div class="menu__item-options">
<% options.forEach(function(option) { %>