Skip to content

Commit

Permalink
feat: Provide details if overwrite dialog appears again
Browse files Browse the repository at this point in the history
Added additional translation string
  • Loading branch information
DailisLangovskis authored and raitisbe committed May 31, 2022
1 parent fd723b5 commit 798dd3d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 23 deletions.
4 changes: 3 additions & 1 deletion projects/hslayers/src/assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
"submitLayerTitle": "Fill in layer title"
},
"dialogOverWrite": {
"overwriteExistingLayer": "Layer already exists! Do You wish to overwrite layer:"
"overwriteExistingLayer": "Layer already exists!",
"doYouWishToOverwrite": "Do You wish to overwrite layer:",
"noteForRepetiveDialog": "*Note: Renaming and uploading layer failed, because such layer name already exists!"
}
},
"ADDLAYERS": {
Expand Down
4 changes: 3 additions & 1 deletion projects/hslayers/src/assets/locales/lv.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
"submitLayerTitle": "Ievadiet slāņa nosaukumu"
},
"dialogOverWrite": {
"overwriteExistingLayer": "Slānis jau eksistē. Vai vēlaties pārrakstīt layer:"
"overwriteExistingLayer": "Slānis jau eksistē!",
"doYouWishToOverwrite": "Vai vēlaties pārrakstīt layer:",
"noteForRepetiveDialog": "*Piezīme: Slāņa pārdēvēšana un augšupielāde neizdevās, jo šāds slāņa nosaukums jau pastāv!"
}
},
"ADDLAYERS": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export class HsAddDataCommonFileService {
async addAsWms(
data: FileDataObject,
app: string,
overwrite?: boolean
options?: {overwrite?: boolean; repetive?: boolean}
): Promise<void> {
try {
const appRef = this.get(app);
Expand Down Expand Up @@ -340,10 +340,10 @@ export class HsAddDataCommonFileService {
data.sld,
data.access_rights,
app,
overwrite
options?.overwrite
);
if (response?.code) {
await this.postLoadNonWmsError(response, data, app);
await this.postLoadNonWmsError(response, data, app, options?.repetive);
} else {
await this.postLoadNonWmsSuccess(response, data, app);
}
Expand All @@ -359,12 +359,14 @@ export class HsAddDataCommonFileService {
*/
async loadOverwriteLayerDialog(
data: FileDataObject | VectorDataObject,
app: string
app: string,
repetive?: boolean
): Promise<OverwriteResponse> {
const dialogRef = this.hsDialogContainerService.create(
HsLayerOverwriteDialogComponent,
{
dataObj: data,
repetive,
app,
},
app
Expand All @@ -381,16 +383,17 @@ export class HsAddDataCommonFileService {
async postLoadNonWmsError(
response: PostPatchLayerResponse,
data: FileDataObject,
app: string
app: string,
repetive?: boolean
): Promise<void> {
if (response.code == 17) {
const result = await this.loadOverwriteLayerDialog(data, app);
const result = await this.loadOverwriteLayerDialog(data, app, repetive);
switch (result) {
case OverwriteResponse.add:
this.addAsWms(data, app);
this.addAsWms(data, app, {repetive: true});
break;
case OverwriteResponse.overwrite:
this.addAsWms(data, app, true);
this.addAsWms(data, app, {overwrite: true});
break;
case OverwriteResponse.cancel:
default:
Expand Down Expand Up @@ -509,11 +512,11 @@ export class HsAddDataCommonFileService {
*/
displayErrorMessage(_options: errorMessageOptions = {}, app: string): void {
this.hsToastService.createToastPopupMessage(
_options.header,
_options?.header ?? '',
_options.message,
{
serviceCalledFrom: 'HsAddDataCommonFileService',
details: _options.details,
details: _options?.details,
},
app
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">{{'ADDDATA.dialogOverWrite.overwriteExistingLayer' | translateHs: {app:
data.app}
}} {{data.dataObj.name}}?</h4>
data.app} }}</h4>
<button type="button" (click)="close()" class="btn-close" data-dismiss="modal"
attr.aria-label="{{'COMMON.close' | translateHs: {app: data.app} }}">
</button>
</div>
<div class="modal-body" style="overflow-y:auto">
<p class="fw-bold h6">{{'ADDDATA.dialogOverWrite.doYouWishToOverwrite' | translateHs: {app:
data.app } }} {{data.dataObj.name}}?</p>
<p *ngIf="data.repetive" class="h6 small">{{'ADDDATA.dialogOverWrite.noteForRepetiveDialog' |
translateHs: {app:
data.app } }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary compositions-btn-overwrite" (click)="overwrite()"
data-dismiss="modal">{{'SAVECOMPOSITION.form.overwrite' | translateHs: {app: data.app} }}</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class HsLayerOverwriteDialogComponent implements HsDialogComponent {
viewRef: ViewRef;
data: {
dataObj: FileDataObject | VectorDataObject;
repetive: boolean;
app: string;
};

Expand Down Expand Up @@ -49,11 +50,14 @@ export class HsLayerOverwriteDialogComponent implements HsDialogComponent {
this.data.app
);
const result = await renameDialogRef.waitResult();
if (result) {
if (!result) {
//Do nothing
} else {
this.data.dataObj.name = result;
this.data.dataObj.title = result;

this.hsDialogContainerService.destroy(this, this.data.app);
this.dialogItem.resolve('add');
}
this.hsDialogContainerService.destroy(this, this.data.app);
this.dialogItem.resolve('add');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,6 @@ export class HsAddDataVectorService {
commonFileRef.endpoint.user
);
return OverwriteResponse.overwrite;
// const found = this.hsMapService
// .getLayersArray(app)
// .filter((l) => getName(l) == data.name);
// if (found) {
// this.hsMapService.apps[app].map.removeLayer(found as any);
// }
}
break;
case OverwriteResponse.add:
Expand Down

0 comments on commit 798dd3d

Please sign in to comment.