@myrmidon/cadmus-part-general-pg 0.2.0 → 0.3.0
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.
- package/esm2020/lib/bibliography-part-feature/edit-bibliography-part.store.mjs +2 -3
- package/esm2020/lib/categories-part-feature/edit-categories-part.store.mjs +2 -3
- package/esm2020/lib/comment-part-feature/edit-comment-part.store.mjs +2 -3
- package/esm2020/lib/doc-references-part-feature/edit-doc-references-part.store.mjs +2 -3
- package/esm2020/lib/historical-date-part-feature/edit-historical-date-part.store.mjs +3 -4
- package/esm2020/lib/index-keywords-part-feature/edit-index-keywords-part.store.mjs +2 -3
- package/esm2020/lib/keywords-part-feature/edit-keywords-part.store.mjs +2 -3
- package/esm2020/lib/note-part-feature/edit-note-part.store.mjs +2 -3
- package/esm2020/lib/tiled-text-layer-part-feature/tiled-text-layer-part-feature.component.mjs +60 -24
- package/esm2020/lib/tiled-text-layer-part-feature/tiled-text-layer-view.mjs +6 -6
- package/esm2020/lib/tiled-text-part-feature/edit-tiled-text-part.service.mjs +3 -3
- package/esm2020/lib/tiled-text-part-feature/edit-tiled-text-part.store.mjs +2 -3
- package/esm2020/lib/tiled-text-part-feature/tiled-text-part-feature.component.mjs +2 -2
- package/esm2020/lib/token-text-layer-part-feature/token-text-layer-part-feature.component.mjs +51 -22
- package/esm2020/lib/token-text-part-feature/edit-token-text-part.store.mjs +2 -3
- package/esm2020/lib/token-text-part-feature/token-text-part-feature.component.mjs +2 -2
- package/fesm2015/myrmidon-cadmus-part-general-pg.mjs +134 -64
- package/fesm2015/myrmidon-cadmus-part-general-pg.mjs.map +1 -1
- package/fesm2020/myrmidon-cadmus-part-general-pg.mjs +129 -64
- package/fesm2020/myrmidon-cadmus-part-general-pg.mjs.map +1 -1
- package/lib/tiled-text-layer-part-feature/tiled-text-layer-part-feature.component.d.ts +12 -12
- package/lib/tiled-text-part-feature/edit-tiled-text-part.service.d.ts +2 -2
- package/lib/token-text-layer-part-feature/token-text-layer-part-feature.component.d.ts +10 -10
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, Component, NgModule } from '@angular/core';
|
|
3
3
|
import * as i5 from '@myrmidon/cadmus-state';
|
|
4
|
-
import {
|
|
4
|
+
import { EditPartQueryBase, EditPartServiceBase, EditPartFeatureBase, editFragmentInitialState, EditFragmentQueryBase, EditFragmentServiceBase, EditFragmentFeatureBase, CadmusStateModule } from '@myrmidon/cadmus-state';
|
|
5
5
|
import * as i1 from '@angular/router';
|
|
6
6
|
import { RouterModule } from '@angular/router';
|
|
7
7
|
import * as i2$1 from '@angular/material/snack-bar';
|
|
@@ -34,7 +34,7 @@ import { NgToolsModule } from '@myrmidon/ng-tools';
|
|
|
34
34
|
|
|
35
35
|
let EditBibliographyPartStore = class EditBibliographyPartStore extends Store {
|
|
36
36
|
constructor() {
|
|
37
|
-
super(
|
|
37
|
+
super({});
|
|
38
38
|
}
|
|
39
39
|
setDirty(value) {
|
|
40
40
|
this.update({ dirty: value });
|
|
@@ -100,7 +100,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
100
100
|
|
|
101
101
|
let EditCategoriesPartStore = class EditCategoriesPartStore extends Store {
|
|
102
102
|
constructor() {
|
|
103
|
-
super(
|
|
103
|
+
super({});
|
|
104
104
|
}
|
|
105
105
|
setDirty(value) {
|
|
106
106
|
this.update({ dirty: value });
|
|
@@ -293,7 +293,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
293
293
|
|
|
294
294
|
let EditCommentPartStore = class EditCommentPartStore extends Store {
|
|
295
295
|
constructor() {
|
|
296
|
-
super(
|
|
296
|
+
super({});
|
|
297
297
|
}
|
|
298
298
|
setDirty(value) {
|
|
299
299
|
this.update({ dirty: value });
|
|
@@ -361,7 +361,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
361
361
|
|
|
362
362
|
let EditDocReferencesPartStore = class EditDocReferencesPartStore extends Store {
|
|
363
363
|
constructor() {
|
|
364
|
-
super(
|
|
364
|
+
super({});
|
|
365
365
|
}
|
|
366
366
|
setDirty(value) {
|
|
367
367
|
this.update({ dirty: value });
|
|
@@ -422,7 +422,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
422
422
|
|
|
423
423
|
let EditHistoricalDatePartStore = class EditHistoricalDatePartStore extends Store {
|
|
424
424
|
constructor() {
|
|
425
|
-
super(
|
|
425
|
+
super({});
|
|
426
426
|
}
|
|
427
427
|
setDirty(value) {
|
|
428
428
|
this.update({ dirty: value });
|
|
@@ -483,7 +483,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
483
483
|
|
|
484
484
|
let EditIndexKeywordsPartStore = class EditIndexKeywordsPartStore extends Store {
|
|
485
485
|
constructor() {
|
|
486
|
-
super(
|
|
486
|
+
super({});
|
|
487
487
|
}
|
|
488
488
|
setDirty(value) {
|
|
489
489
|
this.update({ dirty: value });
|
|
@@ -544,7 +544,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
544
544
|
|
|
545
545
|
let EditKeywordsPartStore = class EditKeywordsPartStore extends Store {
|
|
546
546
|
constructor() {
|
|
547
|
-
super(
|
|
547
|
+
super({});
|
|
548
548
|
}
|
|
549
549
|
setDirty(value) {
|
|
550
550
|
this.update({ dirty: value });
|
|
@@ -605,7 +605,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
605
605
|
|
|
606
606
|
let EditNotePartStore = class EditNotePartStore extends Store {
|
|
607
607
|
constructor() {
|
|
608
|
-
super(
|
|
608
|
+
super({});
|
|
609
609
|
}
|
|
610
610
|
setDirty(value) {
|
|
611
611
|
this.update({ dirty: value });
|
|
@@ -727,8 +727,8 @@ class TiledTextLayerView {
|
|
|
727
727
|
for (let j = 0; j < row.tiles.length; j++) {
|
|
728
728
|
const tile = row.tiles[j];
|
|
729
729
|
row.tiles[j] = {
|
|
730
|
-
checked: hasChecked ? state.checked : tile.checked,
|
|
731
|
-
frIndex: hasFrIndex ? state.frIndex : tile.frIndex,
|
|
730
|
+
checked: (hasChecked ? state.checked : tile.checked) ? true : false,
|
|
731
|
+
frIndex: hasFrIndex ? state.frIndex || -1 : tile.frIndex,
|
|
732
732
|
model: tile.model,
|
|
733
733
|
};
|
|
734
734
|
}
|
|
@@ -965,12 +965,12 @@ class TiledTextLayerView {
|
|
|
965
965
|
y1 = next.y;
|
|
966
966
|
x1 = next.x;
|
|
967
967
|
}
|
|
968
|
+
this.linearSetCheck(y1, x1, yx.y, yx.x, false);
|
|
968
969
|
}
|
|
969
970
|
else {
|
|
970
971
|
y1 = 1;
|
|
971
972
|
x1 = 1;
|
|
972
973
|
}
|
|
973
|
-
this.linearSetCheck(y1, x1, yx.y, yx.x, false);
|
|
974
974
|
}
|
|
975
975
|
}
|
|
976
976
|
/**
|
|
@@ -987,10 +987,10 @@ class TiledTextLayerView {
|
|
|
987
987
|
}
|
|
988
988
|
const end = this.findFirstCheckedCoords(start.y, start.x, false);
|
|
989
989
|
if (!end || (end.y === start.y && end.x === start.x)) {
|
|
990
|
-
return;
|
|
990
|
+
return null;
|
|
991
991
|
}
|
|
992
992
|
const last = this.getPrevTileCoords(end.y, end.x);
|
|
993
|
-
return last.y === start.y && last.x === start.x
|
|
993
|
+
return !last || (last.y === start.y && last.x === start.x)
|
|
994
994
|
? new TokenLocation(new TokenPoint(start.y, start.x))
|
|
995
995
|
: new TokenLocation(new TokenPoint(start.y, start.x), new TokenPoint(last.y, last.x));
|
|
996
996
|
}
|
|
@@ -1068,25 +1068,13 @@ class TiledTextLayerPartFeatureComponent {
|
|
|
1068
1068
|
this.itemId = route.snapshot.params['iid'];
|
|
1069
1069
|
this.partId = route.snapshot.params['pid'];
|
|
1070
1070
|
if (this.partId === 'new') {
|
|
1071
|
-
this.partId =
|
|
1071
|
+
this.partId = undefined;
|
|
1072
1072
|
}
|
|
1073
1073
|
this.roleId = route.snapshot.queryParams['rid'];
|
|
1074
1074
|
if (this.roleId === 'default') {
|
|
1075
|
-
this.roleId =
|
|
1075
|
+
this.roleId = undefined;
|
|
1076
1076
|
}
|
|
1077
1077
|
this.userLevel = authService.getCurrentUserLevel();
|
|
1078
|
-
}
|
|
1079
|
-
canDeactivate() {
|
|
1080
|
-
return true;
|
|
1081
|
-
}
|
|
1082
|
-
ensureItemLoaded(id) {
|
|
1083
|
-
if (!this._editItemQuery.hasItem(id)) {
|
|
1084
|
-
this._editItemService.load(id);
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
ngOnInit() {
|
|
1088
|
-
// base text: connect rows to the base text part
|
|
1089
|
-
this.rows$ = this._editQuery.select((state) => state.baseTextPart?.rows);
|
|
1090
1078
|
// layers part
|
|
1091
1079
|
this.loading$ = this._editQuery.selectLoading();
|
|
1092
1080
|
this.error$ = this._editQuery.selectError();
|
|
@@ -1097,22 +1085,38 @@ class TiledTextLayerPartFeatureComponent {
|
|
|
1097
1085
|
this.layerHints$ = this._editQuery.selectLayerHints();
|
|
1098
1086
|
this.patchingLayer$ = this._editQuery.selectPatchingLayers();
|
|
1099
1087
|
this.deletingFragment$ = this._editQuery.selectDeletingFragment();
|
|
1088
|
+
// base text: connect rows to the base text part
|
|
1089
|
+
this.rows$ = this._editQuery.select((state) => state.baseTextPart?.rows);
|
|
1090
|
+
}
|
|
1091
|
+
canDeactivate() {
|
|
1092
|
+
return true;
|
|
1093
|
+
}
|
|
1094
|
+
ensureItemLoaded(id) {
|
|
1095
|
+
if (!this._editItemQuery.hasItem(id)) {
|
|
1096
|
+
this._editItemService.load(id);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
ngOnInit() {
|
|
1100
1100
|
// when the base text changes, load all the fragments locations
|
|
1101
1101
|
// and setup their UI state
|
|
1102
1102
|
this.rows$.subscribe((rows) => {
|
|
1103
|
-
this.view = rows ? new TiledTextLayerView(rows) :
|
|
1103
|
+
this.view = rows ? new TiledTextLayerView(rows) : undefined;
|
|
1104
1104
|
this.view?.setFragmentLocations(this._editQuery.getValue().locations);
|
|
1105
1105
|
});
|
|
1106
1106
|
// ensure that the container item is loaded
|
|
1107
1107
|
this.ensureItemLoaded(this.itemId);
|
|
1108
1108
|
// load the layer part
|
|
1109
|
-
|
|
1109
|
+
if (this.partId) {
|
|
1110
|
+
this._editService.load(this.itemId, this.partId);
|
|
1111
|
+
}
|
|
1110
1112
|
}
|
|
1111
1113
|
refreshBreakChance() {
|
|
1112
1114
|
this._editService.refreshBreakChance();
|
|
1113
1115
|
}
|
|
1114
1116
|
onTileChecked(y, x, checked) {
|
|
1115
|
-
this.view
|
|
1117
|
+
if (this.view) {
|
|
1118
|
+
this.view.toggleLinearTileCheck(y, x, checked);
|
|
1119
|
+
}
|
|
1116
1120
|
}
|
|
1117
1121
|
getSelectedTileCoords() {
|
|
1118
1122
|
if (!this.selectedTile || !this.view) {
|
|
@@ -1127,6 +1131,9 @@ class TiledTextLayerPartFeatureComponent {
|
|
|
1127
1131
|
return null;
|
|
1128
1132
|
}
|
|
1129
1133
|
selectPrevTile() {
|
|
1134
|
+
if (!this.view) {
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1130
1137
|
let yx = this.getSelectedTileCoords();
|
|
1131
1138
|
if (yx) {
|
|
1132
1139
|
yx = this.view.getPrevTileCoords(yx.y, yx.x);
|
|
@@ -1136,6 +1143,9 @@ class TiledTextLayerPartFeatureComponent {
|
|
|
1136
1143
|
}
|
|
1137
1144
|
}
|
|
1138
1145
|
selectNextTile() {
|
|
1146
|
+
if (!this.view) {
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1139
1149
|
let yx = this.getSelectedTileCoords();
|
|
1140
1150
|
if (yx) {
|
|
1141
1151
|
yx = this.view.getNextTileCoords(yx.y, yx.x);
|
|
@@ -1145,6 +1155,9 @@ class TiledTextLayerPartFeatureComponent {
|
|
|
1145
1155
|
}
|
|
1146
1156
|
}
|
|
1147
1157
|
deleteFragment() {
|
|
1158
|
+
if (!this.view) {
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1148
1161
|
const lf = this.view.getCheckedLocationAndFragment();
|
|
1149
1162
|
if (!lf || lf.fragment === -1) {
|
|
1150
1163
|
return;
|
|
@@ -1156,8 +1169,10 @@ class TiledTextLayerPartFeatureComponent {
|
|
|
1156
1169
|
.subscribe((ok) => {
|
|
1157
1170
|
if (ok) {
|
|
1158
1171
|
// find the fragment and remove it from the part
|
|
1159
|
-
const i = this._editQuery
|
|
1160
|
-
|
|
1172
|
+
const i = this._editQuery
|
|
1173
|
+
.getValue()
|
|
1174
|
+
.part?.fragments.findIndex((p) => {
|
|
1175
|
+
return TokenLocation.parse(p.location)?.overlaps(loc);
|
|
1161
1176
|
});
|
|
1162
1177
|
if (i === -1) {
|
|
1163
1178
|
return;
|
|
@@ -1168,10 +1183,15 @@ class TiledTextLayerPartFeatureComponent {
|
|
|
1168
1183
|
}
|
|
1169
1184
|
deleteFragmentFromHint(hint) {
|
|
1170
1185
|
const loc = TokenLocation.parse(hint.location);
|
|
1171
|
-
|
|
1186
|
+
if (loc) {
|
|
1187
|
+
this._editService.deleteFragment(loc);
|
|
1188
|
+
}
|
|
1172
1189
|
}
|
|
1173
1190
|
navigateToFragmentEditor(loc) {
|
|
1174
1191
|
const part = this._editQuery.getValue().part;
|
|
1192
|
+
if (!part) {
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1175
1195
|
const { route, rid } = this._libraryRouteService.buildFragmentEditorRoute(this._editItemQuery.getValue().facet.partDefinitions, part.itemId, part.id, part.typeId, part.roleId, loc);
|
|
1176
1196
|
// navigate to the editor
|
|
1177
1197
|
this._router.navigate([route], rid
|
|
@@ -1183,6 +1203,9 @@ class TiledTextLayerPartFeatureComponent {
|
|
|
1183
1203
|
: {});
|
|
1184
1204
|
}
|
|
1185
1205
|
editFragment() {
|
|
1206
|
+
if (!this.view) {
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1186
1209
|
const lf = this.view.getCheckedLocationAndFragment();
|
|
1187
1210
|
if (!lf || lf.fragment === -1) {
|
|
1188
1211
|
return;
|
|
@@ -1194,7 +1217,9 @@ class TiledTextLayerPartFeatureComponent {
|
|
|
1194
1217
|
this.navigateToFragmentEditor(hint.location);
|
|
1195
1218
|
}
|
|
1196
1219
|
moveFragmentFromHint(hint) {
|
|
1197
|
-
if (!this.pickedLocation ||
|
|
1220
|
+
if (!this.pickedLocation ||
|
|
1221
|
+
this.pickedLocation === hint.location ||
|
|
1222
|
+
!this.partId) {
|
|
1198
1223
|
return;
|
|
1199
1224
|
}
|
|
1200
1225
|
this._editService.applyLayerPatches(this.partId, [
|
|
@@ -1202,6 +1227,9 @@ class TiledTextLayerPartFeatureComponent {
|
|
|
1202
1227
|
]);
|
|
1203
1228
|
}
|
|
1204
1229
|
addFragment() {
|
|
1230
|
+
if (!this.view) {
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1205
1233
|
const lf = this.view.getCheckedLocationAndFragment();
|
|
1206
1234
|
if (!lf || lf.fragment > -1) {
|
|
1207
1235
|
return;
|
|
@@ -1209,6 +1237,9 @@ class TiledTextLayerPartFeatureComponent {
|
|
|
1209
1237
|
this.navigateToFragmentEditor(lf.location.toString());
|
|
1210
1238
|
}
|
|
1211
1239
|
pickLocation() {
|
|
1240
|
+
if (!this.view) {
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1212
1243
|
const lf = this.view.getCheckedLocationAndFragment();
|
|
1213
1244
|
if (!lf) {
|
|
1214
1245
|
return;
|
|
@@ -1217,11 +1248,16 @@ class TiledTextLayerPartFeatureComponent {
|
|
|
1217
1248
|
this.pickedLocation = (lf.fragment === -1 ? lf.location : locations[lf.fragment]).toString();
|
|
1218
1249
|
}
|
|
1219
1250
|
clearTileChecks() {
|
|
1251
|
+
if (!this.view) {
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1220
1254
|
this.view.setAllTilesViewState({ checked: false });
|
|
1221
|
-
this.pickedLocation =
|
|
1255
|
+
this.pickedLocation = undefined;
|
|
1222
1256
|
}
|
|
1223
1257
|
applyLayerPatches(patches) {
|
|
1224
|
-
|
|
1258
|
+
if (this.partId) {
|
|
1259
|
+
this._editService.applyLayerPatches(this.partId, patches);
|
|
1260
|
+
}
|
|
1225
1261
|
}
|
|
1226
1262
|
close() {
|
|
1227
1263
|
this._router.navigate(['/items', this.itemId]);
|
|
@@ -1236,7 +1272,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
1236
1272
|
|
|
1237
1273
|
let EditTiledTextPartStore = class EditTiledTextPartStore extends Store {
|
|
1238
1274
|
constructor() {
|
|
1239
|
-
super(
|
|
1275
|
+
super({});
|
|
1240
1276
|
}
|
|
1241
1277
|
setDirty(value) {
|
|
1242
1278
|
this.update({ dirty: value });
|
|
@@ -1280,10 +1316,10 @@ class EditTiledTextPartService extends EditPartServiceBase {
|
|
|
1280
1316
|
* @param itemId The item's ID.
|
|
1281
1317
|
* @param thesauriIds The optional thesauri IDs.
|
|
1282
1318
|
*/
|
|
1283
|
-
loadBaseTextPart(itemId, thesauriIds
|
|
1319
|
+
loadBaseTextPart(itemId, thesauriIds) {
|
|
1284
1320
|
// get the base text part ID from the item's ID
|
|
1285
1321
|
this.itemService
|
|
1286
|
-
.getPartFromTypeAndRole(itemId,
|
|
1322
|
+
.getPartFromTypeAndRole(itemId, 'any', 'base-text')
|
|
1287
1323
|
.subscribe((part) => {
|
|
1288
1324
|
this.load(part.id, thesauriIds);
|
|
1289
1325
|
}, (error) => {
|
|
@@ -1303,7 +1339,7 @@ class TiledTextPartFeatureComponent extends EditPartFeatureBase {
|
|
|
1303
1339
|
super(router, route, snackbar, editPartQuery, editPartService, editItemQuery, editItemService);
|
|
1304
1340
|
}
|
|
1305
1341
|
ngOnInit() {
|
|
1306
|
-
this.initEditor(
|
|
1342
|
+
this.initEditor();
|
|
1307
1343
|
}
|
|
1308
1344
|
}
|
|
1309
1345
|
TiledTextPartFeatureComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TiledTextPartFeatureComponent, deps: [{ token: i1.Router }, { token: i1.ActivatedRoute }, { token: i2$1.MatSnackBar }, { token: EditTiledTextPartQuery }, { token: EditTiledTextPartService }, { token: i5.EditItemQuery }, { token: i5.EditItemService }], target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -1334,13 +1370,22 @@ class TokenTextLayerPartFeatureComponent {
|
|
|
1334
1370
|
this.itemId = route.snapshot.params.iid;
|
|
1335
1371
|
this.partId = route.snapshot.params.pid;
|
|
1336
1372
|
if (this.partId === 'new') {
|
|
1337
|
-
this.partId =
|
|
1373
|
+
this.partId = undefined;
|
|
1338
1374
|
}
|
|
1339
1375
|
this.roleId = route.snapshot.queryParams.rid;
|
|
1340
1376
|
if (this.roleId === 'default') {
|
|
1341
|
-
this.roleId =
|
|
1377
|
+
this.roleId = undefined;
|
|
1342
1378
|
}
|
|
1343
1379
|
this.userLevel = authService.getCurrentUserLevel();
|
|
1380
|
+
this.loading$ = this._editQuery.selectLoading();
|
|
1381
|
+
this.error$ = this._editQuery.selectError();
|
|
1382
|
+
this.baseText$ = this._editQuery.select((state) => state.baseText);
|
|
1383
|
+
this.locations$ = this._editQuery.select((state) => state.locations);
|
|
1384
|
+
this.refreshingBreakChance$ = this._editQuery.selectRefreshingBreakChance();
|
|
1385
|
+
this.breakChance$ = this._editQuery.selectBreakChance();
|
|
1386
|
+
this.layerHints$ = this._editQuery.selectLayerHints();
|
|
1387
|
+
this.patchingLayer$ = this._editQuery.selectPatchingLayers();
|
|
1388
|
+
this.deletingFragment$ = this._editQuery.selectDeletingFragment();
|
|
1344
1389
|
}
|
|
1345
1390
|
canDeactivate() {
|
|
1346
1391
|
return true;
|
|
@@ -1365,15 +1410,6 @@ class TokenTextLayerPartFeatureComponent {
|
|
|
1365
1410
|
this.textSize = size;
|
|
1366
1411
|
}
|
|
1367
1412
|
ngOnInit() {
|
|
1368
|
-
this.loading$ = this._editQuery.selectLoading();
|
|
1369
|
-
this.error$ = this._editQuery.selectError();
|
|
1370
|
-
this.baseText$ = this._editQuery.select((state) => state.baseText);
|
|
1371
|
-
this.locations$ = this._editQuery.select((state) => state.locations);
|
|
1372
|
-
this.refreshingBreakChance$ = this._editQuery.selectRefreshingBreakChance();
|
|
1373
|
-
this.breakChance$ = this._editQuery.selectBreakChance();
|
|
1374
|
-
this.layerHints$ = this._editQuery.selectLayerHints();
|
|
1375
|
-
this.patchingLayer$ = this._editQuery.selectPatchingLayers();
|
|
1376
|
-
this.deletingFragment$ = this._editQuery.selectDeletingFragment();
|
|
1377
1413
|
// when the base text changes, load all the fragments locations
|
|
1378
1414
|
// this.baseText$.subscribe(_ => {
|
|
1379
1415
|
// this.loadAllFragmentLocations();
|
|
@@ -1381,10 +1417,16 @@ class TokenTextLayerPartFeatureComponent {
|
|
|
1381
1417
|
// ensure the container item is loaded
|
|
1382
1418
|
this.ensureItemLoaded(this.itemId);
|
|
1383
1419
|
// load the layer part data
|
|
1384
|
-
|
|
1420
|
+
if (this.partId) {
|
|
1421
|
+
this._editService.load(this.itemId, this.partId);
|
|
1422
|
+
}
|
|
1385
1423
|
}
|
|
1386
1424
|
deleteFragment() {
|
|
1387
|
-
const
|
|
1425
|
+
const range = this._textLayerService.getSelectedRange();
|
|
1426
|
+
if (!range) {
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
const location = this._textLayerService.getSelectedLocationForEdit(range);
|
|
1388
1430
|
if (!location) {
|
|
1389
1431
|
return;
|
|
1390
1432
|
}
|
|
@@ -1393,8 +1435,10 @@ class TokenTextLayerPartFeatureComponent {
|
|
|
1393
1435
|
.subscribe((ok) => {
|
|
1394
1436
|
if (ok) {
|
|
1395
1437
|
// find the fragment and remove it from the part
|
|
1396
|
-
const i = this._editQuery
|
|
1397
|
-
|
|
1438
|
+
const i = this._editQuery
|
|
1439
|
+
.getValue()
|
|
1440
|
+
.part.fragments.findIndex((p) => {
|
|
1441
|
+
return TokenLocation.parse(p.location)?.overlaps(location);
|
|
1398
1442
|
});
|
|
1399
1443
|
if (i === -1) {
|
|
1400
1444
|
return;
|
|
@@ -1405,13 +1449,18 @@ class TokenTextLayerPartFeatureComponent {
|
|
|
1405
1449
|
}
|
|
1406
1450
|
deleteFragmentFromHint(hint) {
|
|
1407
1451
|
const loc = TokenLocation.parse(hint.location);
|
|
1408
|
-
|
|
1452
|
+
if (loc) {
|
|
1453
|
+
this._editService.deleteFragment(loc);
|
|
1454
|
+
}
|
|
1409
1455
|
}
|
|
1410
1456
|
refreshBreakChance() {
|
|
1411
1457
|
this._editService.refreshBreakChance();
|
|
1412
1458
|
}
|
|
1413
1459
|
navigateToFragmentEditor(loc) {
|
|
1414
1460
|
const part = this._editQuery.getValue().part;
|
|
1461
|
+
if (!part) {
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1415
1464
|
const { route, rid } = this._libraryRouteService.buildFragmentEditorRoute(this._editItemQuery.getValue().facet.partDefinitions, part.itemId, part.id, part.typeId, part.roleId, loc);
|
|
1416
1465
|
// navigate to the editor
|
|
1417
1466
|
this._router.navigate([route], rid
|
|
@@ -1423,7 +1472,11 @@ class TokenTextLayerPartFeatureComponent {
|
|
|
1423
1472
|
: {});
|
|
1424
1473
|
}
|
|
1425
1474
|
editFragment() {
|
|
1426
|
-
const
|
|
1475
|
+
const range = this._textLayerService.getSelectedRange();
|
|
1476
|
+
if (!range) {
|
|
1477
|
+
return;
|
|
1478
|
+
}
|
|
1479
|
+
const location = this._textLayerService.getSelectedLocationForEdit(range);
|
|
1427
1480
|
if (location) {
|
|
1428
1481
|
this.navigateToFragmentEditor(location.toString());
|
|
1429
1482
|
}
|
|
@@ -1432,13 +1485,19 @@ class TokenTextLayerPartFeatureComponent {
|
|
|
1432
1485
|
this.navigateToFragmentEditor(hint.location);
|
|
1433
1486
|
}
|
|
1434
1487
|
addFragment() {
|
|
1435
|
-
const
|
|
1488
|
+
const range = this._textLayerService.getSelectedRange();
|
|
1489
|
+
if (!range) {
|
|
1490
|
+
return;
|
|
1491
|
+
}
|
|
1492
|
+
const location = this._textLayerService.getSelectedLocationForNew(range, this._editQuery.getValue()?.baseText || '');
|
|
1436
1493
|
if (location) {
|
|
1437
1494
|
this.navigateToFragmentEditor(location.toString());
|
|
1438
1495
|
}
|
|
1439
1496
|
}
|
|
1440
1497
|
moveFragmentFromHint(hint) {
|
|
1441
|
-
if (!this.pickedLocation ||
|
|
1498
|
+
if (!this.pickedLocation ||
|
|
1499
|
+
this.pickedLocation === hint.location ||
|
|
1500
|
+
!this.partId) {
|
|
1442
1501
|
return;
|
|
1443
1502
|
}
|
|
1444
1503
|
this._editService.applyLayerPatches(this.partId, [
|
|
@@ -1446,10 +1505,16 @@ class TokenTextLayerPartFeatureComponent {
|
|
|
1446
1505
|
]);
|
|
1447
1506
|
}
|
|
1448
1507
|
applyLayerPatches(patches) {
|
|
1449
|
-
|
|
1508
|
+
if (this.partId) {
|
|
1509
|
+
this._editService.applyLayerPatches(this.partId, patches);
|
|
1510
|
+
}
|
|
1450
1511
|
}
|
|
1451
1512
|
pickLocation() {
|
|
1452
|
-
const
|
|
1513
|
+
const range = this._textLayerService.getSelectedRange();
|
|
1514
|
+
if (!range) {
|
|
1515
|
+
return;
|
|
1516
|
+
}
|
|
1517
|
+
const location = this._textLayerService.getSelectedLocationForNew(range, this._editQuery.getValue()?.baseText || '');
|
|
1453
1518
|
if (location) {
|
|
1454
1519
|
this.pickedLocation = location.toString();
|
|
1455
1520
|
}
|
|
@@ -1467,7 +1532,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImpor
|
|
|
1467
1532
|
|
|
1468
1533
|
let EditTokenTextPartStore = class EditTokenTextPartStore extends Store {
|
|
1469
1534
|
constructor() {
|
|
1470
|
-
super(
|
|
1535
|
+
super({});
|
|
1471
1536
|
}
|
|
1472
1537
|
setDirty(value) {
|
|
1473
1538
|
this.update({ dirty: value });
|
|
@@ -1516,7 +1581,7 @@ class TokenTextPartFeatureComponent extends EditPartFeatureBase {
|
|
|
1516
1581
|
super(router, route, snackbar, editPartQuery, editPartService, editItemQuery, editItemService);
|
|
1517
1582
|
}
|
|
1518
1583
|
ngOnInit() {
|
|
1519
|
-
this.initEditor(
|
|
1584
|
+
this.initEditor();
|
|
1520
1585
|
}
|
|
1521
1586
|
}
|
|
1522
1587
|
TokenTextPartFeatureComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TokenTextPartFeatureComponent, deps: [{ token: i1.Router }, { token: i1.ActivatedRoute }, { token: i2$1.MatSnackBar }, { token: EditTokenTextPartQuery }, { token: EditTokenTextPartService }, { token: i5.EditItemQuery }, { token: i5.EditItemService }], target: i0.ɵɵFactoryTarget.Component });
|