Skip to content

Commit

Permalink
feat(layermanager): Add copy button to URL
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipLeitner authored and jmacura committed Jul 29, 2024
1 parent cb60f0d commit 6a58830
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 39 deletions.
7 changes: 3 additions & 4 deletions projects/hslayers/assets/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"context": "Kontext",
"continue": "Pokračovat",
"copyLayer": "Kopírovat vrstvu",
"copyToClipboard": "Zkopírovat do schránky",
"data": "Data",
"dataset": "Datová sada",
"date": "Datum",
Expand Down Expand Up @@ -316,7 +317,8 @@
"Tile": "Dlaždice",
"done": "Hotovo",
"group": "skupina",
"separateLayers": "samostatné vrstvy"
"separateLayers": "samostatné vrstvy",
"copyToClipboardFailure": "Nevar kopēt. Jūsu pārlūkprogramma neatbalsta nepieciešamās funkcijas"
},
"COMPOSITIONS": {
"addByAddress": "Přidat kompozici z adresy",
Expand Down Expand Up @@ -752,9 +754,6 @@
"edit": "Upravit"
},
"PERMALINK": {
"directiveMd": {
"copyToClipboard": "Zkopírovat do schránky"
},
"embed": "vložení",
"embedCode": "Vložit kód",
"linkFor": "Odkaz pro",
Expand Down
7 changes: 3 additions & 4 deletions projects/hslayers/assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"context": "Context",
"continue": "Continue",
"copyLayer": "Copy layer",
"copyToClipboard": "Copy to clipboard",
"data": "Data",
"dataset": "Dataset",
"date": "Date",
Expand Down Expand Up @@ -316,7 +317,8 @@
"Tile": "Tile",
"done": "Done",
"group": "group",
"separateLayers": "separate layers"
"separateLayers": "separate layers",
"copyToClipboardFailure": "Could not copy. Clipboard API not supported in your browser."
},
"COMPOSITIONS": {
"addByAddress": "Add composition by address",
Expand Down Expand Up @@ -752,9 +754,6 @@
"edit": "Edit"
},
"PERMALINK": {
"directiveMd": {
"copyToClipboard": "Copy to clipboard"
},
"embed": "embed",
"embedCode": "Embed code",
"linkFor": "Link for",
Expand Down
7 changes: 3 additions & 4 deletions projects/hslayers/assets/locales/lv.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
"context": "Konteksts",
"continue": "turpināt",
"copyLayer": "Kopēt slāni",
"copyToClipboard": "Kopēt starpliktuvē",
"data": "Dati",
"dataset": "Datu kopa",
"date": "Datums",
Expand Down Expand Up @@ -293,7 +294,8 @@
"reorder": "Pārkārtot",
"off": "izslēgts",
"on": "ieslēgts",
"done": "Gatavs"
"done": "Gatavs",
"copyToClipboardFailure": "Nevar kopēt. Jūsu pārlūkprogramma neatbalsta nepieciešamās funkcijas."
},
"COMPOSITIONS": {
"addByAddress": "Pievienot kompozīciju pēc adreses",
Expand Down Expand Up @@ -708,9 +710,6 @@
"edit": "Rediģēt"
},
"PERMALINK": {
"directiveMd": {
"copyToClipboard": "Kopēt starpliktuvē"
},
"embed": "Fiksētās",
"embedCode": "Fiksēt kodu",
"linkFor": "Saite priekš",
Expand Down
7 changes: 3 additions & 4 deletions projects/hslayers/assets/locales/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"context": "Kontext",
"continue": "Pokračovať",
"copyLayer": "Kopírovať vrstvu",
"copyToClipboard": "Skopírovať do schránky",
"data": "Dáta",
"dataset": "Dátová sada",
"date": "Dátum",
Expand Down Expand Up @@ -316,7 +317,8 @@
"Tile": "Dlaždica",
"done": "Hotovo",
"group": "skupina",
"separateLayers": "samostatné vrstvy"
"separateLayers": "samostatné vrstvy",
"copyToClipboardFailure": "Nie je možné kopírovať. \nVáš prehliadač nepodporuje potrebné funkcie."
},
"COMPOSITIONS": {
"addByAddress": "Pridať kompozíciu z adresy",
Expand Down Expand Up @@ -752,9 +754,6 @@
"edit": "Upraviť"
},
"PERMALINK": {
"directiveMd": {
"copyToClipboard": "Skopírovať do schránky"
},
"embed": "vloženie",
"embedCode": "Vložiť kód",
"linkFor": "Odkaz pre",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<div class="form-group">
<small class="text-secondary" *ngIf="(layerDescriptor | async)">
{{
HsLanguageService.getTranslationIgnoreNonExisting(
"LAYERMANAGER.layerEditor",
(layerDescriptor | async).type,
undefined
)
}}<!-- TODO: Remove function call from template -->
<small class="text-secondary" *ngIf="layerDescriptor | async as descriptor">
{{ descriptor.type | translateHs: { module: "LAYERMANAGER.layerEditor" } }}
{{ "LAYERMANAGER.layerEditor.layerFrom" | translateHs }}
<span class="text-truncate mw-100 d-block">
{{
HsLanguageService.getTranslationIgnoreNonExisting(
"LAYERMANAGER.layerEditor",
(layerDescriptor | async).source,
undefined
)
}}<!-- TODO: Remove function call from template -->
</span>
<div class="mw-100 d-flex align-items-center justify-content-between">
<span class="text-truncate">
{{
descriptor.source
| translateHs: { module: "LAYERMANAGER.layerEditor" }
}}
</span>
@if (descriptor.source !== "memory") {
<button class="btn btn-sm text-secondary" data-toggle="tooltip"
[title]="'COMMON.copyToClipboardFailure' | translateHs" (click)="copyToClipBoard()">
<i [class.icon-check]="showCheck" [class.icon-copy]="!showCheck"></i>
</button>
}
</div>
</small>
</div>
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
import {Component} from '@angular/core';
import {Component, inject, signal} from '@angular/core';

import {HsLanguageService} from 'hslayers-ng/services/language';
import {HsLayerEditorWidgetBaseComponent} from './layer-editor-widget-base.component';
import {HsLayerSelectorService} from 'hslayers-ng/services/layer-manager';
import {HsToastService} from 'hslayers-ng/common/toast';

@Component({
selector: 'hs-type-widget',
templateUrl: './type-widget.component.html',
})
export class HsTypeWidgetComponent extends HsLayerEditorWidgetBaseComponent {
constructor(
public HsLanguageService: HsLanguageService,
hsLayerSelectorService: HsLayerSelectorService,
) {
hsToastService = inject(HsToastService);

showCheck = false;

constructor(hsLayerSelectorService: HsLayerSelectorService) {
super(hsLayerSelectorService);
}
name = 'type-widget';

copyToClipBoard() {
if (!navigator.clipboard) {
this.hsToastService.createToastPopupMessage(
'COMMON.copyToClipboard',
'COMMON.copyToClipboardFailure',
{
toastStyleClasses: 'bg-danger text-white',
},
);
return;
}
this.showCheck = true;
const source = this.hsLayerSelectorService.currentLayer.source;
navigator.clipboard.writeText(source);
setTimeout(() => {
this.showCheck = false;
}, 500);
}
}

0 comments on commit 6a58830

Please sign in to comment.