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
|
|
|
|
2021-03-11 05:41:35 +08:00
|
|
|
export const TemplateUserStore = new class {
|
2016-08-17 06:01:20 +08:00
|
|
|
constructor() {
|
2021-01-22 19:23:20 +08:00
|
|
|
this.templates = ko.observableArray();
|
2021-02-10 19:12:36 +08:00
|
|
|
this.templates.loading = ko.observable(false).extend({ debounce: 100 });
|
2016-06-30 08:02:45 +08:00
|
|
|
|
2021-02-10 19:12:36 +08:00
|
|
|
this.templatesNames = ko.observableArray().extend({ debounce: 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
|
|
|
}
|
2021-03-11 05:41:35 +08:00
|
|
|
};
|