2016-08-17 06:01:20 +08:00
|
|
|
import ko from 'ko';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2020-09-15 01:40:56 +08:00
|
|
|
// import Remote from 'Remote/User/Fetch';
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
class TemplateUserStore {
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
|
|
|
this.templates = ko.observableArray([]);
|
2019-07-05 03:19:24 +08:00
|
|
|
this.templates.loading = ko.observable(false).extend({ throttle: 100 });
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2019-07-05 03:19:24 +08:00
|
|
|
this.templatesNames = ko.observableArray([]).extend({ throttle: 1000 });
|
2016-08-17 06:01:20 +08:00
|
|
|
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() {
|
|
|
|
this.templates.subscribe((list) => {
|
2020-10-03 05:54:15 +08:00
|
|
|
this.templatesNames(list.map(item => (item ? item.name : null)).filter(v => v));
|
2016-08-17 06:01:20 +08:00
|
|
|
});
|
|
|
|
|
2017-06-25 03:26:27 +08:00
|
|
|
// this.templatesNames.subscribe((aList) => {
|
|
|
|
// if (this.templatesNames.skipFirst)
|
|
|
|
// {
|
|
|
|
// this.templatesNames.skipFirst = false;
|
|
|
|
// }
|
2020-07-28 18:35:41 +08:00
|
|
|
// else if (aList && aList.length)
|
2017-06-25 03:26:27 +08:00
|
|
|
// {
|
|
|
|
// 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();
|