Skip to content

Commit

Permalink
Merge pull request #747 from JuanTincho/Categories-order. Closes #742
Browse files Browse the repository at this point in the history
Categories order
  • Loading branch information
artf committed Jan 13, 2018
2 parents d8a0ddb + ac31dc3 commit fbd2b51
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/css/grapes.min.css

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions src/block_manager/view/BlocksView.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = Backbone.View.extend({
this.tac = 'test-tac';
this.grabbingCls = this.ppfx + 'grabbing';

if(this.em){
if (this.em) {
this.config.getSorter = this.getSorter;
this.canvas = this.em.get('Canvas');
}
Expand All @@ -32,9 +32,9 @@ module.exports = Backbone.View.extend({
* @private
*/
getSorter() {
if(!this.em)
if (!this.em)
return;
if(!this.sorter){
if (!this.sorter) {
var utils = this.em.get('Utils');
var canvas = this.canvas;
this.sorter = new utils.Sorter({
Expand Down Expand Up @@ -79,7 +79,7 @@ module.exports = Backbone.View.extend({
em.runDefault();

if (model && model.get) {
if(model.get('activeOnRender')) {
if (model.get('activeOnRender')) {
model.trigger('active');
model.set('activeOnRender', 0);
}
Expand Down Expand Up @@ -119,6 +119,8 @@ module.exports = Backbone.View.extend({
id: category,
label: category
};
} else if (typeof category === 'object') {
category.id = category.label;
}

var catModel = this.categories.add(category);
Expand All @@ -139,7 +141,7 @@ module.exports = Backbone.View.extend({
return;
}

if(frag)
if (frag)
frag.appendChild(rendered);
else
this.append(rendered);
Expand Down
5 changes: 3 additions & 2 deletions src/block_manager/view/CategoryView.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ module.exports = Backbone.View.extend({
this.iconClass = `${pfx}caret-icon`;
this.activeClass = `${pfx}open`;
this.className = `${pfx}block-category`;
this.events[`click .${pfx}title`] = 'toggle';
this.events[`click .${pfx}title`] = 'toggle';
this.listenTo(this.model, 'change:open', this.updateVisibility);
this.delegateEvents();
},

updateVisibility() {
if(this.model.get('open'))
if (this.model.get('open'))
this.open();
else
this.close();
Expand Down Expand Up @@ -76,6 +76,7 @@ module.exports = Backbone.View.extend({
label: this.model.get('label'),
});
this.el.className = this.className;
this.$el.css({ 'order': this.model.get('order') });
this.updateVisibility();
return this;
},
Expand Down
5 changes: 5 additions & 0 deletions src/styles/scss/_gjs_blocks.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
justify-content: flex-start;
}

.#{$app-prefix}block-categories {
display: flex;
flex-direction: column;
}

.#{$app-prefix}block-category {
width: 100%;

Expand Down

0 comments on commit fbd2b51

Please sign in to comment.