2015-02-08 09:11:13 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import ko from 'ko';
|
|
|
|
import _ from '_';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-09-13 04:50:21 +08:00
|
|
|
// import Remote from 'Remote/User/Ajax';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
class TemplateUserStore
|
2016-06-30 08:02:45 +08:00
|
|
|
{
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
|
|
|
this.templates = ko.observableArray([]);
|
|
|
|
this.templates.loading = ko.observable(false).extend({throttle: 100});
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.templatesNames = ko.observableArray([]).extend({throttle: 1000});
|
|
|
|
this.templatesNames.skipFirst = true;
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.subscribers();
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
subscribers() {
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.templates.subscribe((list) => {
|
|
|
|
this.templatesNames(_.compact(_.map(list, (item) => (item ? item.name : null))));
|
|
|
|
});
|
|
|
|
|
|
|
|
// this.templatesNames.subscribe((aList) => {
|
2016-06-30 08:02:45 +08:00
|
|
|
// if (this.templatesNames.skipFirst)
|
|
|
|
// {
|
|
|
|
// this.templatesNames.skipFirst = false;
|
|
|
|
// }
|
|
|
|
// else if (aList && 1 < aList.length)
|
|
|
|
// {
|
|
|
|
// Remote.templatesSortOrder(null, aList);
|
|
|
|
// }
|
2016-08-17 06:01:20 +08:00
|
|
|
// });
|
|
|
|
}
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2016-09-13 04:50:21 +08:00
|
|
|
export default new TemplateUserStore();
|