1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

feat(settings): add btn to toggle add project btn

This commit is contained in:
Diptesh Choudhuri 2023-01-25 05:00:31 +00:00
parent 3be80896bb
commit 974e4c39fa
4 changed files with 72 additions and 56 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -2,41 +2,50 @@ PetiteVue.createApp({
//$delimiters: ['${', '}'], // https://github.com/vuejs/petite-vue/pull/100 //$delimiters: ['${', '}'], // https://github.com/vuejs/petite-vue/pull/100
activeTab: defaultTab, activeTab: defaultTab,
selectedTimezone: userTimeZone, selectedTimezone: userTimeZone,
vibrantColorsEnabled: JSON.parse(localStorage.getItem('wakapi_vibrant_colors') || false), vibrantColorsEnabled: JSON.parse(
localStorage.getItem("wakapi_vibrant_colors"),
),
labels: {},
get tzOptions() { get tzOptions() {
return [defaultTzOption, ...tzs.sort().map(tz => ({ value: tz, text: tz }))] return [
defaultTzOption,
...tzs.sort().map((tz) => ({ value: tz, text: tz })),
];
}, },
updateTab() { updateTab() {
this.activeTab = window.location.hash.slice(1) || defaultTab this.activeTab = window.location.hash.slice(1) || defaultTab;
}, },
isActive(tab) { isActive(tab) {
return this.activeTab === tab return this.activeTab === tab;
}, },
confirmRegenerate() { confirmRegenerate() {
if (confirm('Are you sure?')) { if (confirm("Are you sure?")) {
document.querySelector('#form-regenerate-summaries').submit() document.querySelector("#form-regenerate-summaries").submit();
} }
}, },
confirmWakatimeImport() { confirmWakatimeImport() {
if (confirm('Are you sure? The import can not be undone.')) { if (confirm("Are you sure? The import can not be undone.")) {
document.querySelector('#form-import-wakatime').submit() document.querySelector("#form-import-wakatime").submit();
} }
}, },
confirmClearData() { confirmClearData() {
if (confirm('Are you sure? This can not be undone!')) { if (confirm("Are you sure? This can not be undone!")) {
document.querySelector('#form-clear-data').submit() document.querySelector("#form-clear-data").submit();
} }
}, },
confirmDeleteAccount() { confirmDeleteAccount() {
if (confirm('Are you sure? This can not be undone!')) { if (confirm("Are you sure? This can not be undone!")) {
document.querySelector('#form-delete-user').submit() document.querySelector("#form-delete-user").submit();
} }
}, },
onToggleVibrantColors() { onToggleVibrantColors() {
localStorage.setItem('wakapi_vibrant_colors', this.vibrantColorsEnabled) localStorage.setItem("wakapi_vibrant_colors", this.vibrantColorsEnabled);
},
showProjectAddButton(index) {
this.labels[index] = true;
}, },
mounted() { mounted() {
this.updateTab() this.updateTab();
window.addEventListener('hashchange', () => this.updateTab()) window.addEventListener("hashchange", () => this.updateTab());
} },
}).mount('#settings-page') }).mount("#settings-page");

View File

@ -186,7 +186,7 @@
style="line-height: 1.8"> style="line-height: 1.8">
&#9656;&nbsp; All <span class="font-semibold">{{ $alias.Type | typeName }}s</span> named &#9656;&nbsp; All <span class="font-semibold">{{ $alias.Type | typeName }}s</span> named
{{ range $j, $value := $alias.Values }} {{ range $j, $value := $alias.Values }}
<span class="text-white chip text-green-700">{{- $value -}}</span> <span class="chip text-green-700">{{- $value -}}</span>
{{ if lt $j (add (len $alias.Values) -2) }} {{ if lt $j (add (len $alias.Values) -2) }}
<span class="-ml-1">{{- ", " | capitalize -}}</span> <span class="-ml-1">{{- ", " | capitalize -}}</span>
{{ else if lt $j (add (len $alias.Values) -1) }} {{ else if lt $j (add (len $alias.Values) -1) }}
@ -194,7 +194,7 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
are mapped to <span class="font-semibold">{{ $alias.Type | typeName }}</span> <span are mapped to <span class="font-semibold">{{ $alias.Type | typeName }}</span> <span
class="text-white chip text-green-700">{{ $alias.Key }}</span> class="chip text-green-700">{{ $alias.Key }}</span>
</div> </div>
<form class="float-right" action="" method="post"> <form class="float-right" action="" method="post">
<input type="hidden" name="action" value="delete_alias"> <input type="hidden" name="action" value="delete_alias">
@ -255,7 +255,7 @@
<div class="mb-8"> <div class="mb-8">
<h3 class="inline-block font-semibold text-gray-300">Your labels</h3> <h3 class="inline-block font-semibold text-gray-300">Your labels</h3>
{{ range $i, $label := .Labels }} {{ range $i, $label := .Labels }}
<div class="flex items-center"> <div class="flex items-center" data-element-type="label">
<div class="text-gray-500 border-1 w-full border-green-700 inline-block my-1 py-1 text-align text-sm" <div class="text-gray-500 border-1 w-full border-green-700 inline-block my-1 py-1 text-align text-sm"
style="line-height: 1.8"> style="line-height: 1.8">
&#9656;&nbsp;&nbsp;<span class="font-semibold text-gray-300">{{ $label.Key }}:</span> &#9656;&nbsp;&nbsp;<span class="font-semibold text-gray-300">{{ $label.Key }}:</span>
@ -268,7 +268,13 @@
<button type="submit" class="bg-gray-900 text-center hover:bg-gray-700 rounded-full w-4 h-4 leading-none text-red-600" title="Delete label">x</button> <button type="submit" class="bg-gray-900 text-center hover:bg-gray-700 rounded-full w-4 h-4 leading-none text-red-600" title="Delete label">x</button>
</form> </form>
{{ end }} {{ end }}
<form action="" method="post" class="inline-flex space-x-1"> <div class="ml-3 inline">
<button @click="showProjectAddButton({{ $i }})" class="top-1 relative" v-show="!labels[{{ $i }}]">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4 text-gray-400">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
</svg>
</button>
<form action="" method="post" class="inline-flex space-x-1" v-show="labels[{{ $i }}]">
<input type="hidden" name="action" class="block" value="add_label"> <input type="hidden" name="action" class="block" value="add_label">
<input type="hidden" name="value" value="{{ $label.Key }}"> <input type="hidden" name="value" value="{{ $label.Key }}">
<select name="key" class="block text-sm select-default !w-auto"> <select name="key" class="block text-sm select-default !w-auto">
@ -282,6 +288,7 @@
</form> </form>
</div> </div>
</div> </div>
</div>
{{end}} {{end}}
<div class="mb-8"></div> <div class="mb-8"></div>
</div> </div>