- Convert hardcoded strings and French translation keys to English keys across Blade templates, Vue components, TypeScript modules, models, and routes - Complete and synchronize lang/fr.json and lang/en.json translation dictionaries - Add timezone attribute in lang/fr/validation.php and lang/en/validation.php - Add missing English lang files for parity: crud.php, models.php, search.php, and vue.php
101 lines
2.5 KiB
Vue
101 lines
2.5 KiB
Vue
<template>
|
|
<div class="employee-sites-input container-fluid">
|
|
<div class="row">
|
|
<div
|
|
class="col-md-6 col-lg-4"
|
|
v-for="(site, index) in sites"
|
|
:key="index"
|
|
>
|
|
<div class="input-group mb-2">
|
|
<span
|
|
class="input-group-text"
|
|
:id="'site-location-' + index"
|
|
aria-label="Site location"
|
|
>
|
|
<i class="fa-solid fa-location-dot" />
|
|
</span>
|
|
<input
|
|
:aria-labelledby="'site-location-' + index"
|
|
v-model="sites[index]"
|
|
type="text"
|
|
name="employee_sites[]"
|
|
class="form-control text-uppercase font-monospace"
|
|
placeholder="ex: PA"
|
|
maxlength="20"
|
|
required
|
|
>
|
|
<button
|
|
type="button"
|
|
class="btn btn-outline-danger"
|
|
:title="__('Delete this site')"
|
|
@click="removeSite(index)"
|
|
>
|
|
<i class="fa-solid fa-trash" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div
|
|
class="row"
|
|
v-if="sites.length === 0"
|
|
>
|
|
<div class="col">
|
|
<div
|
|
class="alert alert-secondary py-2 mb-2"
|
|
>
|
|
<i class="fa-solid fa-circle-info me-1" />
|
|
<span>{{ __('No site configured. Click the button below to add a site.') }}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col">
|
|
<button
|
|
type="button"
|
|
class="btn btn-sm btn-outline-primary"
|
|
@click="addSite"
|
|
>
|
|
<i class="fa-solid fa-plus me-1" />
|
|
{{ __('Add a site') }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { onMounted, ref, useAttrs } from "vue";
|
|
|
|
import { __ } from "@modules/trans";
|
|
|
|
defineOptions({ name: "EmployeeSitesInputComponent" });
|
|
|
|
const attrs = useAttrs();
|
|
const sites = ref<string[]>([]);
|
|
|
|
onMounted(() => {
|
|
try {
|
|
const rawJson = attrs.json ? String(attrs.json) : "[]";
|
|
const data = typeof attrs.json === "object" ? attrs.json : JSON.parse(rawJson);
|
|
if (Array.isArray(data)) {
|
|
sites.value = [...data];
|
|
} else if (data && Array.isArray(data.sites)) {
|
|
sites.value = [...data.sites];
|
|
}
|
|
} catch (e) {
|
|
console.error("Failed to parse employee sites json", e);
|
|
sites.value = [];
|
|
}
|
|
});
|
|
|
|
const addSite = (): void => {
|
|
sites.value.push("");
|
|
};
|
|
|
|
const removeSite = (index: number): void => {
|
|
sites.value.splice(index, 1);
|
|
};
|
|
</script>
|