@nocobase/actions 1.4.31 → 1.4.32

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.
Files changed (2) hide show
  1. package/lib/actions/move.js +23 -23
  2. package/package.json +5 -5
@@ -32,6 +32,7 @@ __export(move_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(move_exports);
34
34
  var import_sequelize = require("sequelize");
35
+ var import_lodash = require("lodash");
35
36
  var import_database = require("@nocobase/database");
36
37
  var import_utils = require("../utils");
37
38
  async function move(ctx, next) {
@@ -74,42 +75,42 @@ const _SortAbleCollection = class _SortAbleCollection {
74
75
  }
75
76
  // insert source position to target position
76
77
  async move(sourceInstanceId, targetInstanceId, options = {}) {
77
- const sourceInstance = await this.collection.repository.findByTargetKey(sourceInstanceId);
78
+ let sourceInstance = await this.collection.repository.findByTargetKey(sourceInstanceId);
78
79
  const targetInstance = await this.collection.repository.findByTargetKey(targetInstanceId);
79
80
  if (this.scopeKey && sourceInstance.get(this.scopeKey) !== targetInstance.get(this.scopeKey)) {
80
- await sourceInstance.update({
81
- [this.scopeKey]: targetInstance.get(this.scopeKey)
81
+ [sourceInstance] = await this.collection.repository.update({
82
+ filterByTk: sourceInstanceId,
83
+ values: {
84
+ [this.scopeKey]: targetInstance.get(this.scopeKey)
85
+ }
82
86
  });
83
87
  }
84
88
  await this.sameScopeMove(sourceInstance, targetInstance, options);
85
89
  }
86
90
  async changeScope(sourceInstanceId, targetScope, method) {
87
- const sourceInstance = await this.collection.repository.findByTargetKey(sourceInstanceId);
91
+ let sourceInstance = await this.collection.repository.findByTargetKey(sourceInstanceId);
88
92
  const targetScopeValue = targetScope[this.scopeKey];
89
93
  if (targetScopeValue && sourceInstance.get(this.scopeKey) !== targetScopeValue) {
90
- await sourceInstance.update(
91
- {
94
+ [sourceInstance] = await this.collection.repository.update({
95
+ filterByTk: sourceInstanceId,
96
+ values: {
92
97
  [this.scopeKey]: targetScopeValue
93
98
  },
94
- {
95
- silent: false
96
- }
97
- );
99
+ silent: false
100
+ });
98
101
  if (method === "prepend") {
99
102
  await this.sticky(sourceInstanceId);
100
103
  }
101
104
  }
102
105
  }
103
106
  async sticky(sourceInstanceId) {
104
- const sourceInstance = await this.collection.repository.findByTargetKey(sourceInstanceId);
105
- await sourceInstance.update(
106
- {
107
+ await this.collection.repository.update({
108
+ filterByTk: sourceInstanceId,
109
+ values: {
107
110
  [this.field.get("name")]: 0
108
111
  },
109
- {
110
- silent: true
111
- }
112
- );
112
+ silent: true
113
+ });
113
114
  }
114
115
  async sameScopeMove(sourceInstance, targetInstance, options) {
115
116
  const fieldName = this.field.get("name");
@@ -147,14 +148,13 @@ const _SortAbleCollection = class _SortAbleCollection {
147
148
  by: change,
148
149
  silent: true
149
150
  });
150
- await sourceInstance.update(
151
- {
151
+ await this.collection.repository.update({
152
+ filterByTk: this.collection.isMultiFilterTargetKey() ? (0, import_lodash.pick)(sourceInstance, this.collection.filterTargetKey) : sourceInstance.get(this.collection.filterTargetKey),
153
+ values: {
152
154
  [fieldName]: targetSort
153
155
  },
154
- {
155
- silent: true
156
- }
157
- );
156
+ silent: true
157
+ });
158
158
  }
159
159
  };
160
160
  __name(_SortAbleCollection, "SortAbleCollection");
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@nocobase/actions",
3
- "version": "1.4.31",
3
+ "version": "1.4.32",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./lib/index.js",
7
7
  "types": "./lib/index.d.ts",
8
8
  "dependencies": {
9
- "@nocobase/cache": "1.4.31",
10
- "@nocobase/database": "1.4.31",
11
- "@nocobase/resourcer": "1.4.31"
9
+ "@nocobase/cache": "1.4.32",
10
+ "@nocobase/database": "1.4.32",
11
+ "@nocobase/resourcer": "1.4.32"
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/nocobase/nocobase.git",
16
16
  "directory": "packages/actions"
17
17
  },
18
- "gitHead": "931861310dfd8ab019906f8a3a73576922145e63"
18
+ "gitHead": "9dd79ff3198e42c0f6917a678e3325fec7170a87"
19
19
  }