stream filters and panel filters
This commit is contained in:
@@ -25,12 +25,30 @@ Espo.define('controllers/stream', 'controller', function (Dep) {
|
||||
defaultAction: 'index',
|
||||
|
||||
index: function () {
|
||||
this.main('Stream', {
|
||||
this.main('views/stream', {
|
||||
displayTitle: true,
|
||||
}, function (view) {
|
||||
view.render();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
posts: function () {
|
||||
this.main('views/stream', {
|
||||
displayTitle: true,
|
||||
filter: 'posts',
|
||||
}, function (view) {
|
||||
view.render();
|
||||
});
|
||||
},
|
||||
|
||||
updates: function () {
|
||||
this.main('views/stream', {
|
||||
displayTitle: true,
|
||||
filter: 'updates',
|
||||
}, function (view) {
|
||||
view.render();
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -206,6 +206,7 @@ Espo.define('views/record/panels/relationship', ['views/record/panels/bottom', '
|
||||
$el.addClass('hidden');
|
||||
}
|
||||
}, this);
|
||||
this.collection.reset();
|
||||
this.collection.fetch();
|
||||
},
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ Espo.define('views/stream', 'view', function (Dep) {
|
||||
|
||||
filterList: ['all', 'posts', 'updates'],
|
||||
|
||||
filter: 'all',
|
||||
filter: false,
|
||||
|
||||
events: {
|
||||
'click button[data-action="refresh"]': function () {
|
||||
@@ -41,14 +41,20 @@ Espo.define('views/stream', 'view', function (Dep) {
|
||||
},
|
||||
|
||||
data: function () {
|
||||
var filter = this.filter;
|
||||
if (filter === false) {
|
||||
filter = 'all';
|
||||
}
|
||||
return {
|
||||
displayTitle: this.options.displayTitle,
|
||||
filterList: this.filterList,
|
||||
filter: this.filter
|
||||
filter: filter
|
||||
};
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
this.filter = this.options.filter || this.filter;
|
||||
|
||||
this.wait(true);
|
||||
this.getModelFactory().create('Note', function (model) {
|
||||
this.createView('createPost', 'views/stream/record/edit', {
|
||||
@@ -70,6 +76,8 @@ Espo.define('views/stream', 'view', function (Dep) {
|
||||
this.collection = collection;
|
||||
collection.url = 'Stream';
|
||||
|
||||
this.setFilter(this.filter);
|
||||
|
||||
this.listenToOnce(collection, 'sync', function () {
|
||||
this.createView('list', 'views/stream/record/list', {
|
||||
el: this.options.el + ' .list-container',
|
||||
@@ -86,30 +94,39 @@ Espo.define('views/stream', 'view', function (Dep) {
|
||||
|
||||
actionSelectFilter: function (data) {
|
||||
var name = data.name;
|
||||
|
||||
var filter = name;
|
||||
|
||||
if (name == 'all') {
|
||||
filter = false;
|
||||
var internalFilter = name;
|
||||
|
||||
if (filter == 'all') {
|
||||
internalFilter = false;
|
||||
}
|
||||
|
||||
this.setFilter(filter);
|
||||
this.filter = internalFilter;
|
||||
this.setFilter(this.filter);
|
||||
|
||||
this.filterList.forEach(function (item) {
|
||||
var $el = this.$el.find('.page-header button[data-action="selectFilter"][data-name="'+item+'"]');
|
||||
if (item === name) {
|
||||
if (item === filter) {
|
||||
$el.addClass('active');
|
||||
} else {
|
||||
$el.removeClass('active');
|
||||
}
|
||||
}, this);
|
||||
|
||||
var url = '#Stream';
|
||||
if (this.filter) {
|
||||
url += '/' + filter;
|
||||
}
|
||||
this.getRouter().navigate(url);
|
||||
|
||||
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
|
||||
|
||||
this.listenToOnce(this.collection, 'sync', function () {
|
||||
Espo.Ui.notify(false);
|
||||
}, this);
|
||||
|
||||
this.collection.reset();
|
||||
this.collection.fetch();
|
||||
},
|
||||
|
||||
@@ -118,6 +135,8 @@ Espo.define('views/stream', 'view', function (Dep) {
|
||||
if (filter) {
|
||||
this.collection.data.filter = filter;
|
||||
}
|
||||
this.collection.offset = 0;
|
||||
this.collection.maxSize = this.getConfig().get('recordsPerPage') || this.collection.maxSize;
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@@ -327,6 +327,7 @@ Espo.define('views/stream/panel', ['views/record/panels/relationship', 'lib!Text
|
||||
$el.addClass('hidden');
|
||||
}
|
||||
}, this);
|
||||
this.collection.reset();
|
||||
this.collection.fetch();
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user