@etsoo/appscript 1.4.66 → 1.4.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -85,6 +85,16 @@ export declare class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
85
85
  protected sortBase<RQ extends {
86
86
  id: DataTypes.IdType;
87
87
  }>(items: RQ[], payload?: IApiPayload<number>): Promise<number | undefined>;
88
+ /**
89
+ * Sort with category
90
+ * @param category Category for grouping
91
+ * @param items Items to sort
92
+ * @param payload Payload
93
+ * @returns Result
94
+ */
95
+ protected sortWith<RQ extends {
96
+ id: DataTypes.IdType;
97
+ }>(category: number, items: RQ[], payload?: IApiPayload<number>): Promise<number | undefined>;
88
98
  /**
89
99
  * Update
90
100
  * @param data Modal data
@@ -101,6 +101,18 @@ class EntityApi extends BaseApi_1.BaseApi {
101
101
  items.forEach((item, index) => (rq[item.id] = index));
102
102
  return this.api.put(`${this.flag}/Sort`, rq, payload);
103
103
  }
104
+ /**
105
+ * Sort with category
106
+ * @param category Category for grouping
107
+ * @param items Items to sort
108
+ * @param payload Payload
109
+ * @returns Result
110
+ */
111
+ sortWith(category, items, payload) {
112
+ const data = {};
113
+ items.forEach((item, index) => (data[item.id] = index));
114
+ return this.api.put(`${this.flag}/Sort`, { category, data }, payload);
115
+ }
104
116
  /**
105
117
  * Update
106
118
  * @param data Modal data
@@ -85,6 +85,16 @@ export declare class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
85
85
  protected sortBase<RQ extends {
86
86
  id: DataTypes.IdType;
87
87
  }>(items: RQ[], payload?: IApiPayload<number>): Promise<number | undefined>;
88
+ /**
89
+ * Sort with category
90
+ * @param category Category for grouping
91
+ * @param items Items to sort
92
+ * @param payload Payload
93
+ * @returns Result
94
+ */
95
+ protected sortWith<RQ extends {
96
+ id: DataTypes.IdType;
97
+ }>(category: number, items: RQ[], payload?: IApiPayload<number>): Promise<number | undefined>;
88
98
  /**
89
99
  * Update
90
100
  * @param data Modal data
@@ -98,6 +98,18 @@ export class EntityApi extends BaseApi {
98
98
  items.forEach((item, index) => (rq[item.id] = index));
99
99
  return this.api.put(`${this.flag}/Sort`, rq, payload);
100
100
  }
101
+ /**
102
+ * Sort with category
103
+ * @param category Category for grouping
104
+ * @param items Items to sort
105
+ * @param payload Payload
106
+ * @returns Result
107
+ */
108
+ sortWith(category, items, payload) {
109
+ const data = {};
110
+ items.forEach((item, index) => (data[item.id] = index));
111
+ return this.api.put(`${this.flag}/Sort`, { category, data }, payload);
112
+ }
101
113
  /**
102
114
  * Update
103
115
  * @param data Modal data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.4.66",
3
+ "version": "1.4.67",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -160,6 +160,23 @@ export class EntityApi<T extends IApp = IApp> extends BaseApi<T> {
160
160
  return this.api.put(`${this.flag}/Sort`, rq, payload);
161
161
  }
162
162
 
163
+ /**
164
+ * Sort with category
165
+ * @param category Category for grouping
166
+ * @param items Items to sort
167
+ * @param payload Payload
168
+ * @returns Result
169
+ */
170
+ protected sortWith<RQ extends { id: DataTypes.IdType }>(
171
+ category: number,
172
+ items: RQ[],
173
+ payload?: IApiPayload<number>
174
+ ) {
175
+ const data: Record<DataTypes.IdType, number> = {};
176
+ items.forEach((item, index) => (data[item.id] = index));
177
+ return this.api.put(`${this.flag}/Sort`, { category, data }, payload);
178
+ }
179
+
163
180
  /**
164
181
  * Update
165
182
  * @param data Modal data