Jonathan Druart
e90ccb7ff3
On bug 33103 we are adding the ability to filter vendors by aliases. To make it possible in the ERM module we are adding the alias list in the dropdown list. However it's not nicely displayed, especially if there are several entries. This patch suggests to display the aliases in a different line, and not for the selected option. To acchieve that we create a new Vue component FormSelectVendors. Test plan: Create several vendors, and add some aliases to them (keep one vendor without alias) Go to the ERM module go to the following page, search for vendors by aliases, save the form, and confirm that everything is nice and works correctly: * Add/edit an agreement * Add/edit a license * Add/edit a local package * Add a new package to a title (edit a title) Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
134 lines
4.6 KiB
Vue
134 lines
4.6 KiB
Vue
<template>
|
|
<fieldset class="rows" id="resources">
|
|
<legend>{{ $__("Packages") }}</legend>
|
|
<fieldset
|
|
class="rows"
|
|
v-for="(resource, counter) in resources"
|
|
v-bind:key="counter"
|
|
>
|
|
<legend>
|
|
{{ $__("Package %s").format(counter + 1) }}
|
|
<a href="#" @click.prevent="deletePackage(counter)"
|
|
><i class="fa fa-trash"></i>
|
|
{{ $__("Remove from this package") }}</a
|
|
>
|
|
</legend>
|
|
<ol>
|
|
<li>
|
|
<label
|
|
:for="`resource_package_id_${counter}`"
|
|
class="required"
|
|
>{{ $__("Package") }}:
|
|
</label>
|
|
<!-- Parse to integer, resource.package_id is an integer, but GET /packages return package_id as string -->
|
|
<v-select
|
|
:id="`resource_package_id_${counter}`"
|
|
v-model="resource.package_id"
|
|
label="name"
|
|
:reduce="p => parseInt(p.package_id)"
|
|
:options="packages"
|
|
>
|
|
<template #search="{ attributes, events }">
|
|
<input
|
|
:required="!resource.package_id"
|
|
class="vs__search"
|
|
v-bind="attributes"
|
|
v-on="events"
|
|
/>
|
|
</template>
|
|
</v-select>
|
|
<span class="required">{{ $__("Required") }}</span>
|
|
</li>
|
|
<li>
|
|
<label :for="`resource_vendor_id_${counter}`"
|
|
>{{ $__("Vendor") }}:</label
|
|
>
|
|
<FormSelectVendors
|
|
:id="`resource_vendor_id_${counter}`"
|
|
v-model="resource.vendor_id"
|
|
/>
|
|
</li>
|
|
|
|
<li>
|
|
<label :for="`started_on_${counter}`"
|
|
>{{ $__("Start date") }}:
|
|
</label>
|
|
<flat-pickr
|
|
:id="`started_on_${counter}`"
|
|
v-model="resource.started_on"
|
|
:config="fp_config"
|
|
:data-date_to="`ended_on_${counter}`"
|
|
/>
|
|
</li>
|
|
<li>
|
|
<label :for="`ended_on_${counter}`"
|
|
>{{ $__("End date") }}:</label
|
|
>
|
|
<flat-pickr
|
|
:id="`ended_on_${counter}`"
|
|
v-model="resource.ended_on"
|
|
:config="fp_config"
|
|
/>
|
|
</li>
|
|
<li>
|
|
<label :for="`${counter}`">{{ $__("Proxy") }}:</label>
|
|
<input
|
|
:id="`proxy_${counter}`"
|
|
v-model="resource.proxy"
|
|
:placeholder="$__('Proxy')"
|
|
/>
|
|
</li>
|
|
</ol>
|
|
</fieldset>
|
|
<a v-if="packages.length" class="btn btn-default" @click="addPackage"
|
|
><font-awesome-icon icon="plus" />
|
|
{{ $__("Add to another package") }}</a
|
|
>
|
|
<span v-else>{{ $__("There are no packages created yet") }}</span>
|
|
</fieldset>
|
|
</template>
|
|
|
|
<script>
|
|
import flatPickr from "vue-flatpickr-component"
|
|
import { APIClient } from "../../fetch/api-client.js"
|
|
import FormSelectVendors from "../FormSelectVendors.vue"
|
|
|
|
export default {
|
|
setup() {},
|
|
data() {
|
|
return {
|
|
packages: [],
|
|
fp_config: flatpickr_defaults,
|
|
}
|
|
},
|
|
beforeCreate() {
|
|
const client = APIClient.erm
|
|
client.localPackages.getAll().then(
|
|
packages => {
|
|
this.packages = packages
|
|
this.initialized = true
|
|
},
|
|
error => {}
|
|
)
|
|
},
|
|
methods: {
|
|
addPackage() {
|
|
this.resources.push({
|
|
package_id: null,
|
|
vendor_id: null,
|
|
started_on: null,
|
|
ended_on: null,
|
|
proxy: "",
|
|
})
|
|
},
|
|
deletePackage(counter) {
|
|
this.resources.splice(counter, 1)
|
|
},
|
|
},
|
|
props: {
|
|
resources: Array,
|
|
},
|
|
components: { flatPickr, FormSelectVendors },
|
|
name: "EHoldingsLocalTitlesFormAddResources",
|
|
}
|
|
</script>
|