roboto-js 1.4.14 → 1.4.15

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.
@@ -119,7 +119,7 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
119
119
  key: "save",
120
120
  value: function () {
121
121
  var _save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
122
- var record, response;
122
+ var _response$data, _response$data2, record, response;
123
123
  return _regeneratorRuntime().wrap(function _callee$(_context) {
124
124
  while (1) switch (_context.prev = _context.next) {
125
125
  case 0:
@@ -141,24 +141,33 @@ var RbtObject = exports["default"] = /*#__PURE__*/function () {
141
141
  }
142
142
  throw new Error(response.data.message);
143
143
  case 9:
144
- this._internalData = response.data;
144
+ if (!(((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.result) == 'NO_CHANGES')) {
145
+ _context.next = 11;
146
+ break;
147
+ }
148
+ return _context.abrupt("return", this);
149
+ case 11:
150
+ if ((_response$data2 = response.data) !== null && _response$data2 !== void 0 && _response$data2.newData) {
151
+ // apply new incoming data
152
+ this.setData(response.newData);
153
+ }
145
154
  this.id = response.data.id;
146
155
  this.id_revision = response.data.id_revision;
147
156
  this.type = response.data.type;
148
157
  this.rpcMeta.isNew = false;
149
158
  return _context.abrupt("return", this);
150
- case 17:
151
- _context.prev = 17;
159
+ case 19:
160
+ _context.prev = 19;
152
161
  _context.t0 = _context["catch"](2);
153
162
  console.log('RbtObject.save.error:', _context.t0);
154
163
  this._error = _context.t0;
155
164
  //console.log(e.response.data);
156
165
  throw _context.t0;
157
- case 22:
166
+ case 24:
158
167
  case "end":
159
168
  return _context.stop();
160
169
  }
161
- }, _callee, this, [[2, 17]]);
170
+ }, _callee, this, [[2, 19]]);
162
171
  }));
163
172
  function save() {
164
173
  return _save.apply(this, arguments);
@@ -91,7 +91,13 @@ export default class RbtObject {
91
91
  if (response.data.ok === false) {
92
92
  throw new Error(response.data.message);
93
93
  }
94
- this._internalData = response.data;
94
+ if (response.data?.result == 'NO_CHANGES') {
95
+ return this;
96
+ }
97
+ if (response.data?.newData) {
98
+ // apply new incoming data
99
+ this.setData(response.newData);
100
+ }
95
101
  this.id = response.data.id;
96
102
  this.id_revision = response.data.id_revision;
97
103
  this.type = response.data.type;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.14",
3
+ "version": "1.4.15",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_object.js CHANGED
@@ -106,7 +106,14 @@ export default class RbtObject {
106
106
  throw new Error(response.data.message);
107
107
  }
108
108
 
109
- this._internalData = response.data;
109
+ if(response.data?.result == 'NO_CHANGES'){
110
+ return this;
111
+ }
112
+
113
+ if(response.data?.newData){
114
+ // apply new incoming data
115
+ this.setData(response.newData);
116
+ }
110
117
 
111
118
  this.id = response.data.id;
112
119
  this.id_revision = response.data.id_revision;