@@ -13544,18 +13544,6 @@ function (_Mutations) {
13544
13544
value: function setStatements(payload) {
13545
13545
external_commonjs_vue2_commonjs2_vue2_amd_vue2_root_vue2_default.a.set(this.state, payload.entityId, clone(payload.statements));
13546
13546
}
13547
- }, {
13548
- key: "setDataValue",
13549
- value: function setDataValue(payload) {
13550
- var snak = payload.path.resolveSnakInStatement(this.state);
13551
- external_commonjs_vue2_commonjs2_vue2_amd_vue2_root_vue2_default.a.set(snak, 'datavalue', payload.value);
13552
- }
13553
- }, {
13554
- key: "setSnakType",
13555
- value: function setSnakType(payload) {
13556
- var snak = payload.path.resolveSnakInStatement(this.state);
13557
- snak.snaktype = payload.value;
13558
- }
13559
13547
}]);
13560
13548
13561
13549
return StatementMutations;
@@ -13580,6 +13568,7 @@ var SnakActionErrors;
13580
13568
13581
13569
13582
13570
13571
+
13583
13572
var actions_StatementActions =
13584
13573
/*#__PURE__*/
13585
13574
function (_Actions) {
@@ -13601,12 +13590,13 @@ function (_Actions) {
13601
13590
return Promise.resolve();
13602
13591
}
13603
13592
}, {
13604
- key: "setStringDataValue ",
13605
- value: function setStringDataValue (payloadDataValue) {
13593
+ key: "applyStringDataValue ",
13594
+ value: function applyStringDataValue (payloadDataValue) {
13606
13595
var _this = this;
13607
13596
13608
13597
return new Promise(function (resolve) {
13609
- var snak = payloadDataValue.path.resolveSnakInStatement(_this.state);
13598
+ var state = clone(_this.state);
13599
+ var snak = payloadDataValue.path.resolveSnakInStatement(state);
13610
13600
13611
13601
if (snak === null) {
13612
13602
throw new Error(storeActionErrors_SnakActionErrors.NO_SNAK_FOUND);
@@ -13618,19 +13608,11 @@ function (_Actions) {
13618
13608
13619
13609
if (typeof payloadDataValue.value.value !== 'string') {
13620
13610
throw new Error(storeActionErrors_SnakActionErrors.WRONG_PAYLOAD_VALUE_TYPE);
13621
- } // TODO put more validation here
13622
-
13623
-
13624
- var payloadSnakType = {
13625
- path: payloadDataValue.path,
13626
- value: 'value'
13627
- };
13628
-
13629
- _this.commit('setSnakType', payloadSnakType);
13630
-
13631
- _this.commit('setDataValue', payloadDataValue);
13611
+ }
13632
13612
13633
- resolve();
13613
+ snak.snaktype = 'value';
13614
+ snak.datavalue = payloadDataValue.value;
13615
+ resolve(state);
13634
13616
});
13635
13617
}
13636
13618
}]);
@@ -13813,12 +13795,12 @@ function (_Actions) {
13813
13795
}
13814
13796
}, {
13815
13797
key: "entitySave",
13816
- value: function entitySave() {
13798
+ value: function entitySave(statements ) {
13817
13799
var _this2 = this;
13818
13800
13819
13801
var entityRevision = new EntityRevision_EntityRevision({
13820
13802
id: this.state.id,
13821
- statements: this.statementsModule.state[this.state.id]
13803
+ statements: statements
13822
13804
}, this.state.baseRevision);
13823
13805
return this.store.$services.get('writingEntityRepository').saveEntity(entityRevision).then(function (entityRevision) {
13824
13806
return _this2.dispatch('entityWrite', entityRevision);
@@ -13970,7 +13952,7 @@ function (_Actions) {
13970
13952
var _postEntityLoad = _asyncToGenerator(
13971
13953
/*#__PURE__*/
13972
13954
regeneratorRuntime.mark(function _callee2() {
13973
- var state, path, originalStatement ;
13955
+ var state, path;
13974
13956
return regeneratorRuntime.wrap(function _callee2$(_context2) {
13975
13957
while (1) {
13976
13958
switch (_context2.prev = _context2.next) {
@@ -13982,10 +13964,9 @@ function (_Actions) {
13982
13964
13983
13965
case 4:
13984
13966
if (this.getters.applicationStatus !== definitions_ApplicationStatus.ERROR) {
13985
- originalStatement = state[NS_STATEMENTS][path.entityId][path.propertyId][path.index];
13986
- this.commit('setOriginalStatement', originalStatement);
13987
13967
this.commit('setTargetValue', // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13988
- originalStatement.mainsnak.datavalue);
13968
+ state[NS_STATEMENTS][path.entityId][path.propertyId][path.index] // TODO use getter
13969
+ .mainsnak.datavalue);
13989
13970
this.commit('setApplicationStatus', definitions_ApplicationStatus.READY);
13990
13971
}
13991
13972
@@ -14083,8 +14064,6 @@ function (_Actions) {
14083
14064
}, {
14084
14065
key: "setTargetValue",
14085
14066
value: function setTargetValue(dataValue) {
14086
- var _this3 = this;
14087
-
14088
14067
if (this.state.applicationStatus !== definitions_ApplicationStatus.READY) {
14089
14068
this.commit('addApplicationErrors', [{
14090
14069
type: ErrorTypes.APPLICATION_LOGIC_ERROR,
@@ -14096,46 +14075,85 @@ function (_Actions) {
14096
14075
}
14097
14076
14098
14077
this.commit('setTargetValue', dataValue);
14099
- var state = this.state;
14100
- var path = new MainSnakPath_MainSnakPath(state[NS_ENTITY].id, state.targetProperty, 0);
14101
- return this.statementModule.dispatch('setStringDataValue', {
14102
- path: path,
14103
- value: dataValue
14104
- }).catch(function (error) {
14105
- _this3.commit('addApplicationErrors', [{
14106
- type: ErrorTypes.APPLICATION_LOGIC_ERROR,
14107
- info: error
14108
- }]);
14109
-
14110
- throw error;
14111
- });
14078
+ return Promise.resolve();
14112
14079
}
14113
14080
}, {
14114
14081
key: "saveBridge",
14115
- value: function saveBridge() {
14116
- var _this4 = this;
14082
+ value: function () {
14083
+ var _saveBridge = _asyncToGenerator(
14084
+ /*#__PURE__*/
14085
+ regeneratorRuntime.mark(function _callee3() {
14086
+ var _this3 = this;
14117
14087
14118
- if (this.state.applicationStatus !== definitions_ApplicationStatus.READY) {
14119
- this.commit('addApplicationErrors', [{
14120
- type: ErrorTypes.APPLICATION_LOGIC_ERROR,
14121
- info: {
14122
- stack: new Error().stack
14088
+ var state, entityId, path, statements;
14089
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
14090
+ while (1) {
14091
+ switch (_context3.prev = _context3.next) {
14092
+ case 0:
14093
+ if (!(this.state.applicationStatus !== definitions_ApplicationStatus.READY)) {
14094
+ _context3.next = 3;
14095
+ break;
14096
+ }
14097
+
14098
+ this.commit('addApplicationErrors', [{
14099
+ type: ErrorTypes.APPLICATION_LOGIC_ERROR,
14100
+ info: {
14101
+ stack: new Error().stack
14102
+ }
14103
+ }]);
14104
+ return _context3.abrupt("return", Promise.reject(null));
14105
+
14106
+ case 3:
14107
+ state = this.state;
14108
+ entityId = state[NS_ENTITY].id;
14109
+ path = new MainSnakPath_MainSnakPath(entityId, state.targetProperty, 0);
14110
+ _context3.prev = 6;
14111
+ _context3.next = 9;
14112
+ return this.statementModule.dispatch('applyStringDataValue', {
14113
+ path: path,
14114
+ value: state.targetValue
14115
+ });
14116
+
14117
+ case 9:
14118
+ statements = _context3.sent;
14119
+ _context3.next = 16;
14120
+ break;
14121
+
14122
+ case 12:
14123
+ _context3.prev = 12;
14124
+ _context3.t0 = _context3["catch"](6);
14125
+ this.commit('addApplicationErrors', [{
14126
+ type: ErrorTypes.APPLICATION_LOGIC_ERROR,
14127
+ info: _context3.t0
14128
+ }]);
14129
+ throw _context3.t0;
14130
+
14131
+ case 16:
14132
+ return _context3.abrupt("return", this.entityModule.dispatch('entitySave', statements[entityId]).catch(function (error) {
14133
+ _this3.commit('addApplicationErrors', [{
14134
+ type: ErrorTypes.SAVING_FAILED,
14135
+ info: error
14136
+ }]);
14137
+
14138
+ throw error;
14139
+ }).then(function () {
14140
+ return _this3.dispatch('postEntityLoad');
14141
+ }));
14142
+
14143
+ case 17:
14144
+ case "end":
14145
+ return _context3.stop();
14146
+ }
14123
14147
}
14124
- }]);
14125
- return Promise.reject(null);
14126
- }
14148
+ }, _callee3, this, [[6, 12]]);
14149
+ }));
14127
14150
14128
- return this.entityModule.dispatch('entitySave').catch(function (error) {
14129
- _this4.commit('addApplicationErrors', [{
14130
- type: ErrorTypes.SAVING_FAILED,
14131
- info: error
14132
- }]);
14151
+ function saveBridge() {
14152
+ return _saveBridge.apply(this, arguments);
14153
+ }
14133
14154
14134
- throw error;
14135
- }).then(function () {
14136
- return _this4.dispatch('postEntityLoad');
14137
- });
14138
- }
14155
+ return saveBridge;
14156
+ }()
14139
14157
}, {
14140
14158
key: "addError",
14141
14159
value: function addError(errors) {
@@ -14209,22 +14227,22 @@ function (_Getters) {
14209
14227
return statements.references ? statements.references : [];
14210
14228
}
14211
14229
}, {
14212
- key: "isTargetStatementModified ",
14230
+ key: "isTargetValueModified ",
14213
14231
get: function get() {
14214
14232
if (this.state.applicationStatus !== definitions_ApplicationStatus.READY) {
14215
14233
return false;
14216
14234
}
14217
14235
14218
14236
var initState = this.state;
14219
14237
var entityId = initState[NS_ENTITY].id;
14220
- return !deep_equal_default()(this.state.originalStatement , initState[NS_STATEMENTS][entityId][this.state.targetProperty][0], {
14238
+ return !deep_equal_default()(this.state.targetValue , initState[NS_STATEMENTS][entityId][this.state.targetProperty][0].mainsnak.datavalue , {
14221
14239
strict: true
14222
14240
});
14223
14241
}
14224
14242
}, {
14225
14243
key: "canSave",
14226
14244
get: function get() {
14227
- return this.state.editDecision !== null && this.getters.isTargetStatementModified ;
14245
+ return this.state.editDecision !== null && this.getters.isTargetValueModified ;
14228
14246
}
14229
14247
}, {
14230
14248
key: "applicationStatus",
@@ -14316,11 +14334,6 @@ function (_Mutations) {
14316
14334
value: function setTargetLabel(label) {
14317
14335
this.state.targetLabel = label;
14318
14336
}
14319
- }, {
14320
- key: "setOriginalStatement",
14321
- value: function setOriginalStatement(revision) {
14322
- this.state.originalStatement = clone(revision);
14323
- }
14324
14337
}, {
14325
14338
key: "addApplicationErrors",
14326
14339
value: function addApplicationErrors(errors) {
@@ -14370,7 +14383,6 @@ var state_BaseState = function BaseState() {
14370
14383
this.editFlow = '';
14371
14384
this.entityTitle = '';
14372
14385
this.originalHref = '';
14373
- this.originalStatement = null;
14374
14386
this.pageTitle = '';
14375
14387
this.targetLabel = null;
14376
14388
this.targetProperty = '';
0 commit comments