Bug 38664: (re)Tidy the .vue files - 'semi: true'

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2025-02-06 21:43:08 +01:00 committed by Katrin Fischer
parent aa24f1e6d1
commit 8fb8590600
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
74 changed files with 2471 additions and 2460 deletions

View File

@ -26,12 +26,12 @@ export default {
data() {
return {
fields_to_display: [],
}
};
},
name: "AdditionalFieldsDisplay",
props: {
resource_type: String,
additional_field_values: Array,
},
}
};
</script>

View File

@ -125,7 +125,7 @@
</template>
<script>
import { APIClient } from "../fetch/api-client.js"
import { APIClient } from "../fetch/api-client.js";
export default {
data() {
@ -133,17 +133,17 @@ export default {
available_fields: [],
av_options: [],
current_additional_fields_values: {},
}
};
},
beforeCreate() {
const client = APIClient.additional_fields
const client = APIClient.additional_fields;
client.additional_fields.getAll(this.resource_type).then(
available_fields => {
this.available_fields = available_fields
this.initialized = true
this.available_fields = available_fields;
this.initialized = true;
},
error => {}
)
);
},
watch: {
current_additional_fields_values: {
@ -151,15 +151,15 @@ export default {
handler(current_additional_fields_values) {
this.updateParentAdditionalFieldValues(
current_additional_fields_values
)
);
},
},
available_fields: function (available_fields) {
if (available_fields) {
const client_av = APIClient.authorised_values
const client_av = APIClient.authorised_values;
let av_cat_array = available_fields
.map(field => field.authorised_value_category_name)
.filter(field => field)
.filter(field => field);
client_av.values
.getCategoriesWithValues([
@ -171,20 +171,20 @@ export default {
av_cat_array.forEach(av_cat => {
let av_match = av_categories.find(
element => element.category_name == av_cat
)
);
this.av_options[av_cat] =
av_match.authorised_values.map(av => ({
value: av.value,
label: av.description,
}))
})
}));
});
// Iterate on available fields
available_fields.forEach(available_field => {
// Initialize current field as empty array
this.current_additional_fields_values[
available_field.extended_attribute_type_id
] = []
] = [];
// Grab all existing field values of this field
let existing_field_values =
@ -193,13 +193,13 @@ export default {
afv.field_id ==
available_field.extended_attribute_type_id &&
afv.value
)
);
// If there are existing field values for this field, add them to current_additional_fields_values
if (existing_field_values.length) {
existing_field_values.forEach(
existing_field_value => {
let label = ""
let label = "";
if (
available_field.authorised_value_category_name
) {
@ -210,19 +210,19 @@ export default {
av_option =>
av_option.value ==
existing_field_value.value
)
);
label = av_value.length
? av_value[0].label
: ""
: "";
}
this.current_additional_fields_values[
existing_field_value.field_id
].push({
value: existing_field_value.value,
label: label,
})
});
}
)
);
// Otherwise add them as empty if not AV field
} else {
@ -236,32 +236,32 @@ export default {
label: "",
value: "",
},
]
];
}
}
})
})
});
});
}
},
},
methods: {
clearField: function (current_field, event) {
event.preventDefault()
current_field.value = ""
event.preventDefault();
current_field.value = "";
},
cloneField: function (available_field, current, event) {
event.preventDefault()
event.preventDefault();
this.current_additional_fields_values[
available_field.extended_attribute_type_id
].push({
value: current.value,
label: available_field.name,
})
});
},
updateParentAdditionalFieldValues: function (
current_additional_fields_values
) {
let updatedAdditionalFields = []
let updatedAdditionalFields = [];
Object.keys(current_additional_fields_values).forEach(field_id => {
if (
!Array.isArray(
@ -271,7 +271,7 @@ export default {
) {
current_additional_fields_values[field_id] = [
current_additional_fields_values[field_id],
]
];
}
if (current_additional_fields_values[field_id]) {
let new_extended_attributes =
@ -280,14 +280,14 @@ export default {
field_id: field_id,
value: value.value,
})
)
);
updatedAdditionalFields = updatedAdditionalFields.concat(
new_extended_attributes
)
);
}
})
});
this.$emit("additional-fields-changed", updatedAdditionalFields)
this.$emit("additional-fields-changed", updatedAdditionalFields);
},
},
name: "AdditionalFieldsEntry",
@ -295,5 +295,5 @@ export default {
resource_type: String,
additional_field_values: Array,
},
}
};
</script>

View File

@ -53,16 +53,16 @@
</template>
<script>
import { inject } from "vue"
import { setMessage, setError, setWarning } from "../../../messages"
import { APIClient } from "../../../fetch/api-client.js"
import { inject } from "vue";
import { setMessage, setError, setWarning } from "../../../messages";
import { APIClient } from "../../../fetch/api-client.js";
export default {
setup() {
const { setMessage } = inject("mainStore")
const { setMessage } = inject("mainStore");
return {
setMessage,
}
};
},
data() {
return {
@ -72,58 +72,58 @@ export default {
can_be_edited: false,
},
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (to.params.record_source_id) {
vm.getRecordSource(to.params.record_source_id)
vm.getRecordSource(to.params.record_source_id);
} else {
vm.initialized = true
vm.initialized = true;
}
})
});
},
methods: {
async getRecordSource(record_source_id) {
const client = APIClient.record_sources
const client = APIClient.record_sources;
client.record_sources.get(record_source_id).then(
record_source => {
this.record_source = record_source
this.record_source_id = record_source_id
this.initialized = true
this.record_source = record_source;
this.record_source_id = record_source_id;
this.initialized = true;
},
error => {}
)
);
},
onSubmit(e) {
e.preventDefault()
const client = APIClient.record_sources
let response
e.preventDefault();
const client = APIClient.record_sources;
let response;
// RO attribute
delete this.record_source.record_source_id
delete this.record_source.record_source_id;
if (this.record_source_id) {
// update
response = client.record_sources
.update(this.record_source, this.record_source_id)
.then(
success => {
setMessage(this.$__("Record source updated!"))
this.$router.push({ name: "RecordSourcesList" })
setMessage(this.$__("Record source updated!"));
this.$router.push({ name: "RecordSourcesList" });
},
error => {}
)
);
} else {
response = client.record_sources
.create(this.record_source)
.then(
success => {
setMessage(this.$__("Record source created!"))
this.$router.push({ name: "RecordSourcesList" })
setMessage(this.$__("Record source created!"));
this.$router.push({ name: "RecordSourcesList" });
},
error => {}
)
);
}
},
},
}
};
</script>

View File

@ -24,11 +24,11 @@
</template>
<script>
import Toolbar from "../../Toolbar.vue"
import ToolbarButton from "../../ToolbarButton.vue"
import { inject } from "vue"
import { APIClient } from "../../../fetch/api-client.js"
import KohaTable from "../../KohaTable.vue"
import Toolbar from "../../Toolbar.vue";
import ToolbarButton from "../../ToolbarButton.vue";
import { inject } from "vue";
import { APIClient } from "../../../fetch/api-client.js";
import KohaTable from "../../KohaTable.vue";
export default {
data() {
@ -55,7 +55,7 @@ export default {
render: function (data, type, row, meta) {
return escape_str(
row.can_be_edited ? __("Yes") : __("No")
)
);
},
},
],
@ -75,41 +75,41 @@ export default {
},
initialized: false,
record_sources_count: 0,
}
};
},
setup() {
const { setWarning, setMessage, setError, setConfirmationDialog } =
inject("mainStore")
inject("mainStore");
return {
setWarning,
setMessage,
setError,
setConfirmationDialog,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getRecordSourcesCount().then(() => (vm.initialized = true))
})
vm.getRecordSourcesCount().then(() => (vm.initialized = true));
});
},
methods: {
async getRecordSourcesCount() {
const client = APIClient.record_sources
const client = APIClient.record_sources;
await client.record_sources.count().then(
count => {
this.record_sources_count = count
this.record_sources_count = count;
},
error => {}
)
);
},
newRecordSource() {
this.$router.push({ name: "RecordSourcesFormAdd" })
this.$router.push({ name: "RecordSourcesFormAdd" });
},
doEdit: function ({ record_source_id }, dt, event) {
this.$router.push({
name: "RecordSourcesFormAddEdit",
params: { record_source_id },
})
});
},
doDelete: function (record_source, dt, event) {
this.setConfirmationDialog(
@ -122,7 +122,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.record_sources
const client = APIClient.record_sources;
client.record_sources
.delete(record_source.record_source_id)
.then(
@ -132,13 +132,13 @@ export default {
"Record source '%s' deleted"
).format(record_source.name),
true
)
dt.draw()
);
dt.draw();
},
error => {}
)
);
}
)
);
},
},
components: {
@ -146,5 +146,5 @@ export default {
Toolbar,
ToolbarButton,
},
}
};
</script>

View File

@ -18,9 +18,9 @@
</template>
<script>
import Breadcrumbs from "../../Breadcrumbs.vue"
import Help from "../../Help.vue"
import Dialog from "../../Dialog.vue"
import Breadcrumbs from "../../Breadcrumbs.vue";
import Help from "../../Help.vue";
import Dialog from "../../Dialog.vue";
export default {
components: {
@ -28,7 +28,7 @@ export default {
Dialog,
Help,
},
}
};
</script>
<style></style>

View File

@ -22,22 +22,22 @@
</nav>
</template>
<script>
import { inject } from "vue"
import { storeToRefs } from "pinia"
import NavigationItem from "./NavigationItem.vue"
import { inject } from "vue";
import { storeToRefs } from "pinia";
import NavigationItem from "./NavigationItem.vue";
export default {
name: "Breadcrumbs",
setup: () => {
const navigationStore = inject("navigationStore")
const { breadcrumbs } = storeToRefs(navigationStore)
const { params } = navigationStore
const navigationStore = inject("navigationStore");
const { breadcrumbs } = storeToRefs(navigationStore);
const { params } = navigationStore;
return {
breadcrumbs,
params,
}
};
},
components: {
NavigationItem,
},
}
};
</script>

View File

@ -12,5 +12,5 @@ export default {
required: false,
},
},
}
};
</script>

View File

@ -116,14 +116,14 @@
</template>
<script>
import { inject, watch, nextTick } from "vue"
import { storeToRefs } from "pinia"
import flatPickr from "vue-flatpickr-component"
import { inject, watch, nextTick } from "vue";
import { storeToRefs } from "pinia";
import flatPickr from "vue-flatpickr-component";
export default {
data() {
return {
fp_config: flatpickr_defaults,
}
};
},
methods: {
submit: function (e) {
@ -135,18 +135,18 @@ export default {
(input.value == null || input.value == "")
).length
) {
this.$refs.confirmationform.reportValidity()
this.$refs.confirmationform.reportValidity();
} else {
this.accept_callback().then(() => {
nextTick(() => {
$("#confirmation.modal").modal("hide")
})
})
$("#confirmation.modal").modal("hide");
});
});
}
},
},
setup() {
const mainStore = inject("mainStore")
const mainStore = inject("mainStore");
const {
message,
error,
@ -155,28 +155,28 @@ export default {
accept_callback,
is_submitting,
is_loading,
} = storeToRefs(mainStore)
const { removeMessages, removeConfirmationMessages } = mainStore
} = storeToRefs(mainStore);
const { removeMessages, removeConfirmationMessages } = mainStore;
watch(warning, newWarning => {
if (!newWarning) {
$("#warning.modal").modal("hide")
return
$("#warning.modal").modal("hide");
return;
}
nextTick(() => {
$("#warning.modal").modal("show")
})
})
$("#warning.modal").modal("show");
});
});
watch(confirmation, newConfirmation => {
if (!newConfirmation) {
$("#confirmation.modal").modal("hide")
return
$("#confirmation.modal").modal("hide");
return;
}
nextTick(() => {
$("#confirmation.modal").modal("show")
})
})
$("#confirmation.modal").modal("show");
});
});
return {
message,
@ -188,12 +188,12 @@ export default {
is_loading,
removeMessages,
removeConfirmationMessages,
}
};
},
components: {
flatPickr,
},
}
};
</script>
<style scoped>

View File

@ -94,15 +94,15 @@
</template>
<script>
import { APIClient } from "../../fetch/api-client.js"
import InfiniteScrollSelect from "../InfiniteScrollSelect.vue"
import { APIClient } from "../../fetch/api-client.js";
import InfiniteScrollSelect from "../InfiniteScrollSelect.vue";
export default {
name: "AgreementLicenses",
data() {
return {
license_count: null,
}
};
},
props: {
av_agreement_license_statuses: Array,
@ -110,14 +110,14 @@ export default {
agreement_licenses: Array,
},
beforeCreate() {
const client = APIClient.erm
const client = APIClient.erm;
client.licenses.count().then(
count => {
this.license_count = count
this.initialized = true
this.license_count = count;
this.initialized = true;
},
error => {}
)
);
},
methods: {
addLicense() {
@ -128,14 +128,14 @@ export default {
notes: "",
uri: "",
license: { name: "" },
})
});
},
deleteLicense(counter) {
this.agreement_licenses.splice(counter, 1)
this.agreement_licenses.splice(counter, 1);
},
},
components: {
InfiniteScrollSelect,
},
}
};
</script>

View File

@ -67,13 +67,13 @@
</template>
<script>
import flatPickr from "vue-flatpickr-component"
import flatPickr from "vue-flatpickr-component";
export default {
name: "AgreementPeriods",
data() {
return {
fp_config: flatpickr_defaults,
}
};
},
props: {
periods: Array,
@ -85,14 +85,14 @@ export default {
ended_on: null,
cancellation_deadline: null,
notes: null,
})
});
},
deletePeriod(counter) {
this.periods.splice(counter, 1)
this.periods.splice(counter, 1);
},
},
components: {
flatPickr,
},
}
};
</script>

View File

@ -89,25 +89,25 @@
</template>
<script>
import { APIClient } from "../../fetch/api-client.js"
import { APIClient } from "../../fetch/api-client.js";
export default {
data() {
return {
agreements: [],
}
};
},
beforeCreate() {
const client = APIClient.erm
const client = APIClient.erm;
client.agreements
.getAll({ "me.agreement_id": { "!=": this.agreement_id } })
.then(
agreements => {
this.agreements = agreements
this.initialized = true
this.agreements = agreements;
this.initialized = true;
},
error => {}
)
);
},
methods: {
addRelationship() {
@ -115,10 +115,10 @@ export default {
related_agreement_id: null,
relationship: null,
notes: "",
})
});
},
deleteRelationship(counter) {
this.relationships.splice(counter, 1)
this.relationships.splice(counter, 1);
},
},
props: {
@ -127,5 +127,5 @@ export default {
relationships: Array,
},
name: "AgreementRelationships",
}
};
</script>

View File

@ -173,22 +173,22 @@
</template>
<script>
import { inject } from "vue"
import AgreementPeriods from "./AgreementPeriods.vue"
import UserRoles from "./UserRoles.vue"
import AgreementLicenses from "./AgreementLicenses.vue"
import AgreementRelationships from "./AgreementRelationships.vue"
import Documents from "./Documents.vue"
import AdditionalFieldsEntry from "../AdditionalFieldsEntry.vue"
import ButtonSubmit from "../ButtonSubmit.vue"
import FormSelectVendors from "../FormSelectVendors.vue"
import { setMessage, setError, setWarning } from "../../messages"
import { APIClient } from "../../fetch/api-client.js"
import { storeToRefs } from "pinia"
import { inject } from "vue";
import AgreementPeriods from "./AgreementPeriods.vue";
import UserRoles from "./UserRoles.vue";
import AgreementLicenses from "./AgreementLicenses.vue";
import AgreementRelationships from "./AgreementRelationships.vue";
import Documents from "./Documents.vue";
import AdditionalFieldsEntry from "../AdditionalFieldsEntry.vue";
import ButtonSubmit from "../ButtonSubmit.vue";
import FormSelectVendors from "../FormSelectVendors.vue";
import { setMessage, setError, setWarning } from "../../messages";
import { APIClient } from "../../fetch/api-client.js";
import { storeToRefs } from "pinia";
export default {
setup() {
const AVStore = inject("AVStore")
const AVStore = inject("AVStore");
const {
av_agreement_statuses,
av_agreement_closure_reasons,
@ -197,7 +197,7 @@ export default {
av_agreement_license_statuses,
av_agreement_license_location,
av_agreement_relationships,
} = storeToRefs(AVStore)
} = storeToRefs(AVStore);
return {
av_agreement_statuses,
@ -208,7 +208,7 @@ export default {
av_agreement_license_location,
av_agreement_relationships,
max_allowed_packet,
}
};
},
data() {
return {
@ -230,76 +230,80 @@ export default {
extended_attributes: [],
},
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (to.params.agreement_id) {
vm.getAgreement(to.params.agreement_id)
vm.getAgreement(to.params.agreement_id);
} else {
vm.initialized = true
vm.initialized = true;
}
})
});
},
methods: {
async getAgreement(agreement_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.agreements.get(agreement_id).then(
data => {
this.agreement = data
this.initialized = true
this.agreement = data;
this.initialized = true;
},
error => {}
)
);
},
checkForm(agreement) {
let errors = []
let errors = [];
let agreement_licenses = agreement.agreement_licenses
let agreement_licenses = agreement.agreement_licenses;
// Do not use al.license.name here! Its name is not the one linked with al.license_id
// At this point al.license is meaningless, form/template only modified al.license_id
const license_ids = agreement_licenses.map(al => al.license_id)
const license_ids = agreement_licenses.map(al => al.license_id);
const duplicate_license_ids = license_ids.filter(
(id, i) => license_ids.indexOf(id) !== i
)
);
if (duplicate_license_ids.length) {
errors.push(this.$__("A license is used several times"))
errors.push(this.$__("A license is used several times"));
}
const related_agreement_ids = agreement.agreement_relationships.map(
rs => rs.related_agreement_id
)
);
const duplicate_related_agreement_ids =
related_agreement_ids.filter(
(id, i) => related_agreement_ids.indexOf(id) !== i
)
);
if (duplicate_related_agreement_ids.length) {
errors.push(
this.$__(
"An agreement is used as relationship several times"
)
)
);
}
if (
agreement_licenses.filter(al => al.status == "controlling")
.length > 1
) {
errors.push(this.$__("Only one controlling license is allowed"))
errors.push(
this.$__("Only one controlling license is allowed")
);
}
if (
agreement_licenses.filter(al => al.status == "controlling")
.length > 1
) {
errors.push(this.$__("Only one controlling license is allowed"))
errors.push(
this.$__("Only one controlling license is allowed")
);
}
let documents_with_uploaded_files = agreement.documents.filter(
doc => typeof doc.file_content !== "undefined"
)
);
if (
documents_with_uploaded_files.filter(
doc => atob(doc.file_content).length >= max_allowed_packet
@ -309,7 +313,7 @@ export default {
this.$__("File size exceeds maximum allowed: %s MB").format(
(max_allowed_packet / (1024 * 1024)).toFixed(2)
)
)
);
}
agreement.user_roles.forEach((user, i) => {
if (user.patron_str === "") {
@ -317,40 +321,40 @@ export default {
this.$__("Agreement user %s is missing a user").format(
i + 1
)
)
);
}
})
setWarning(errors.join("<br>"))
return !errors.length
});
setWarning(errors.join("<br>"));
return !errors.length;
},
onSubmit(e) {
e.preventDefault()
e.preventDefault();
//let agreement= Object.assign( {} ,this.agreement); // copy
let agreement = JSON.parse(JSON.stringify(this.agreement)) // copy
let agreement_id = agreement.agreement_id
let agreement = JSON.parse(JSON.stringify(this.agreement)); // copy
let agreement_id = agreement.agreement_id;
if (!this.checkForm(agreement)) {
return false
return false;
}
delete agreement.agreement_id
delete agreement.vendor
delete agreement._strings
agreement.is_perpetual = agreement.is_perpetual ? true : false
delete agreement.agreement_id;
delete agreement.vendor;
delete agreement._strings;
agreement.is_perpetual = agreement.is_perpetual ? true : false;
if (agreement.vendor_id == "") {
agreement.vendor_id = null
agreement.vendor_id = null;
}
agreement.periods = agreement.periods.map(
({ agreement_id, agreement_period_id, ...keepAttrs }) =>
keepAttrs
)
);
agreement.user_roles = agreement.user_roles.map(
({ patron, patron_str, ...keepAttrs }) => keepAttrs
)
);
agreement.agreement_licenses = agreement.agreement_licenses.map(
({
@ -359,45 +363,45 @@ export default {
agreement_license_id,
...keepAttrs
}) => keepAttrs
)
);
agreement.agreement_relationships =
agreement.agreement_relationships.map(
({ related_agreement, ...keepAttrs }) => keepAttrs
)
);
agreement.documents = agreement.documents.map(
({ file_type, uploaded_on, ...keepAttrs }) => keepAttrs
)
);
delete agreement.agreement_packages
delete agreement.agreement_packages;
const client = APIClient.erm
const client = APIClient.erm;
if (agreement_id) {
client.agreements.update(agreement, agreement_id).then(
success => {
setMessage(this.$__("Agreement updated"))
this.$router.push({ name: "AgreementsList" })
setMessage(this.$__("Agreement updated"));
this.$router.push({ name: "AgreementsList" });
},
error => {}
)
);
} else {
client.agreements.create(agreement).then(
success => {
setMessage(this.$__("Agreement created"))
this.$router.push({ name: "AgreementsList" })
setMessage(this.$__("Agreement created"));
this.$router.push({ name: "AgreementsList" });
},
error => {}
)
);
}
},
onStatusChanged(e) {
if (e.value != "closed") {
this.agreement.closure_reason = ""
this.agreement.closure_reason = "";
}
},
additionalFieldsChanged(additionalFieldValues) {
this.agreement.extended_attributes = additionalFieldValues
this.agreement.extended_attributes = additionalFieldValues;
},
},
components: {
@ -411,5 +415,5 @@ export default {
AdditionalFieldsEntry,
},
name: "AgreementsFormAdd",
}
};
</script>

View File

@ -58,32 +58,32 @@
</template>
<script>
import flatPickr from "vue-flatpickr-component"
import Toolbar from "../Toolbar.vue"
import ToolbarButton from "../ToolbarButton.vue"
import { inject, ref, reactive } from "vue"
import { APIClient } from "../../fetch/api-client.js"
import { storeToRefs } from "pinia"
import { build_url } from "../../composables/datatables"
import KohaTable from "../KohaTable.vue"
import flatPickr from "vue-flatpickr-component";
import Toolbar from "../Toolbar.vue";
import ToolbarButton from "../ToolbarButton.vue";
import { inject, ref, reactive } from "vue";
import { APIClient } from "../../fetch/api-client.js";
import { storeToRefs } from "pinia";
import { build_url } from "../../composables/datatables";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const vendorStore = inject("vendorStore")
const { vendors } = storeToRefs(vendorStore)
const vendorStore = inject("vendorStore");
const { vendors } = storeToRefs(vendorStore);
const AVStore = inject("AVStore")
const { get_lib_from_av, map_av_dt_filter } = AVStore
const AVStore = inject("AVStore");
const { get_lib_from_av, map_av_dt_filter } = AVStore;
const { setConfirmationDialog, setMessage } = inject("mainStore")
const { setConfirmationDialog, setMessage } = inject("mainStore");
const table = ref()
const table = ref();
const filters = reactive({
by_expired: false,
max_expiration_date: "",
by_mine: false,
})
});
return {
vendors,
get_lib_from_av,
@ -95,18 +95,18 @@ export default {
escape_str,
agreement_table_settings,
filters,
}
};
},
data: function () {
this.filters.by_expired =
this.$route.query.by_expired === "true" || false
this.filters.by_mine = this.$route.query.by_mine || false
this.$route.query.by_expired === "true" || false;
this.filters.by_mine = this.$route.query.by_mine || false;
this.filters.max_expiration_date =
this.$route.query.max_expiration_date || ""
this.$route.query.max_expiration_date || "";
let filters = this.filters
let filters = this.filters;
let logged_in_user = this.logged_in_user
let logged_in_user = this.logged_in_user;
return {
fp_config: flatpickr_defaults,
agreement_count: 0,
@ -124,9 +124,9 @@ export default {
filters_options: {
1: () =>
this.vendors.map(e => {
e["_id"] = e["id"]
e["_str"] = e["name"]
return e
e["_id"] = e["id"];
e["_str"] = e["name"];
return e;
}),
3: () => this.map_av_dt_filter("av_agreement_statuses"),
4: () =>
@ -157,13 +157,13 @@ export default {
"user_roles.user_id": function () {
return filters.by_mine
? logged_in_user.borrowernumber
: ""
: "";
},
},
},
before_route_entered: false,
building_table: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
@ -175,36 +175,36 @@ export default {
.getSearchableAVOptions()
.then(() => (vm.initialized = true))
)
)
})
);
});
},
methods: {
async getAgreementCount() {
const client = APIClient.erm
const client = APIClient.erm;
await client.agreements.count().then(
count => {
this.agreement_count = count
this.agreement_count = count;
},
error => {}
)
);
},
async getSearchableAdditionalFields() {
const client = APIClient.additional_fields
const client = APIClient.additional_fields;
await client.additional_fields.getAll("agreement").then(
searchable_additional_fields => {
this.searchable_additional_fields =
searchable_additional_fields.filter(
field => field.searchable
)
);
},
error => {}
)
);
},
async getSearchableAVOptions() {
const client_av = APIClient.authorised_values
const client_av = APIClient.authorised_values;
let av_cat_array = this.searchable_additional_fields
.filter(field => field.authorised_value_category_name)
.map(field => field.authorised_value_category_name)
.map(field => field.authorised_value_category_name);
await client_av.values
.getCategoriesWithValues([
@ -214,27 +214,27 @@ export default {
av_cat_array.forEach(av_cat => {
let av_match = av_categories.find(
element => element.category_name == av_cat
)
);
this.searchable_av_options[av_cat] =
av_match.authorised_values.map(av => ({
value: av.value,
label: av.description,
}))
})
})
}));
});
});
},
doShow: function ({ agreement_id }, dt, event) {
event.preventDefault()
event.preventDefault();
this.$router.push({
name: "AgreementsShow",
params: { agreement_id },
})
});
},
doEdit: function ({ agreement_id }, dt, event) {
this.$router.push({
name: "AgreementsFormAddEdit",
params: { agreement_id },
})
});
},
doDelete: function (agreement, dt, event) {
this.setConfirmationDialog(
@ -247,7 +247,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
const client = APIClient.erm;
client.agreements.delete(agreement.agreement_id).then(
success => {
this.setMessage(
@ -255,27 +255,27 @@ export default {
agreement.name
),
true
)
dt.draw()
);
dt.draw();
},
error => {}
)
);
}
)
);
},
doSelect: function (agreement, dt, event) {
this.$emit("select-agreement", agreement.agreement_id)
this.$emit("close")
this.$emit("select-agreement", agreement.agreement_id);
this.$emit("close");
},
get_today_date: function () {
return new Date().toISOString().substring(0, 10)
return new Date().toISOString().substring(0, 10);
},
table_url: function () {
let url = "/api/v1/erm/agreements"
let url = "/api/v1/erm/agreements";
if (this.filters.by_expired)
url +=
"?max_expiration_date=" + this.filters.max_expiration_date
return url
"?max_expiration_date=" + this.filters.max_expiration_date;
return url;
},
filter_table: async function () {
if (!this.embedded) {
@ -283,20 +283,20 @@ export default {
this.filters.by_expired &&
!this.filters.max_expiration_date
) {
this.filters.max_expiration_date = this.get_today_date()
this.filters.max_expiration_date = this.get_today_date();
}
if (!this.filters.by_expired) {
this.filters.max_expiration_date = ""
this.filters.max_expiration_date = "";
}
let { href } = this.$router.resolve({ name: "AgreementsList" })
let new_route = build_url(href, this.filters)
this.$router.push(new_route)
let { href } = this.$router.resolve({ name: "AgreementsList" });
let new_route = build_url(href, this.filters);
this.$router.push(new_route);
}
this.$refs.table.redraw(this.table_url())
this.$refs.table.redraw(this.table_url());
},
getTableColumns: function () {
let get_lib_from_av = this.get_lib_from_av
let escape_str = this.escape_str
let get_lib_from_av = this.get_lib_from_av;
let escape_str = this.escape_str;
return [
{
@ -311,7 +311,7 @@ export default {
'" class="show">' +
escape_str(`${row.name} (#${row.agreement_id})`) +
"</a>"
)
);
},
},
{
@ -326,7 +326,7 @@ export default {
'">' +
escape_str(row.vendor.name) +
"</a>"
: ""
: "";
},
},
{
@ -343,7 +343,7 @@ export default {
render: function (data, type, row, meta) {
return escape_str(
get_lib_from_av("av_agreement_statuses", row.status)
)
);
},
},
{
@ -357,7 +357,7 @@ export default {
"av_agreement_closure_reasons",
row.closure_reason
)
)
);
},
},
{
@ -368,7 +368,7 @@ export default {
render: function (data, type, row, meta) {
return escape_str(
row.is_perpetual ? __("Yes") : __("No")
)
);
},
},
{
@ -382,23 +382,23 @@ export default {
"av_agreement_renewal_priorities",
row.renewal_priority
)
)
);
},
},
]
];
},
},
mounted() {
if (this.embedded) {
this.getAgreementCount().then(() => (this.initialized = true))
this.getAgreementCount().then(() => (this.initialized = true));
}
},
watch: {
"filters.by_expired": function (newVal, oldVal) {
if (newVal) {
this.filters.max_expiration_date = this.get_today_date()
this.filters.max_expiration_date = this.get_today_date();
} else {
this.filters.max_expiration_date = ""
this.filters.max_expiration_date = "";
}
},
},
@ -411,7 +411,7 @@ export default {
},
name: "AgreementsList",
emits: ["select-agreement", "close"],
}
};
</script>
<style scoped>

View File

@ -341,21 +341,21 @@
</template>
<script>
import { inject } from "vue"
import { APIClient } from "../../fetch/api-client.js"
import Toolbar from "../Toolbar.vue"
import ToolbarButton from "../ToolbarButton.vue"
import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue"
import { inject } from "vue";
import { APIClient } from "../../fetch/api-client.js";
import Toolbar from "../Toolbar.vue";
import ToolbarButton from "../ToolbarButton.vue";
import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue";
export default {
setup() {
const format_date = $date
const patron_to_html = $patron_to_html
const format_date = $date;
const patron_to_html = $patron_to_html;
const { setConfirmationDialog, setMessage } = inject("mainStore")
const { setConfirmationDialog, setMessage } = inject("mainStore");
const AVStore = inject("AVStore")
const { get_lib_from_av } = AVStore
const AVStore = inject("AVStore");
const { get_lib_from_av } = AVStore;
return {
format_date,
@ -363,7 +363,7 @@ export default {
get_lib_from_av,
setConfirmationDialog,
setMessage,
}
};
},
data() {
return {
@ -385,26 +385,26 @@ export default {
agreement_packages: [],
},
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getAgreement(to.params.agreement_id)
})
vm.getAgreement(to.params.agreement_id);
});
},
beforeRouteUpdate(to, from) {
this.agreement = this.getAgreement(to.params.agreement_id)
this.agreement = this.getAgreement(to.params.agreement_id);
},
methods: {
async getAgreement(agreement_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.agreements.get(agreement_id).then(
agreement => {
this.agreement = agreement
this.initialized = true
this.agreement = agreement;
this.initialized = true;
},
error => {}
)
);
},
delete_agreement: function (agreement_id, agreement_name) {
this.setConfirmationDialog(
@ -417,7 +417,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
const client = APIClient.erm;
client.agreements.delete(agreement_id).then(
success => {
this.setMessage(
@ -425,18 +425,18 @@ export default {
agreement_name
),
true
)
this.$router.push({ name: "AgreementsList" })
);
this.$router.push({ name: "AgreementsList" });
},
error => {}
)
);
}
)
);
},
},
components: { Toolbar, ToolbarButton, AdditionalFieldsDisplay },
name: "AgreementsShow",
}
};
</script>
<style scoped>
#agreement_documents ul {

View File

@ -108,21 +108,21 @@
<script>
export default {
setup() {
const format_date = $date
return { format_date }
const format_date = $date;
return { format_date };
},
methods: {
selectFile(e, i) {
let files = e.target.files
if (!files) return
let file = files[0]
const reader = new FileReader()
reader.onload = e => this.loadFile(file.name, e.target.result, i)
reader.readAsBinaryString(file)
let files = e.target.files;
if (!files) return;
let file = files[0];
const reader = new FileReader();
reader.onload = e => this.loadFile(file.name, e.target.result, i);
reader.readAsBinaryString(file);
},
loadFile(filename, content, i) {
this.documents[i].file_name = filename
this.documents[i].file_content = btoa(content)
this.documents[i].file_name = filename;
this.documents[i].file_content = btoa(content);
},
addDocument() {
this.documents.push({
@ -133,15 +133,15 @@ export default {
physical_location: null,
uri: null,
notes: null,
})
});
},
deleteDocument(counter) {
this.documents.splice(counter, 1)
this.documents.splice(counter, 1);
},
},
name: "Documents",
props: {
documents: Array,
},
}
};
</script>

View File

@ -68,89 +68,89 @@
</template>
<script>
import AgreementsList from "./AgreementsList.vue"
import { APIClient } from "../../fetch/api-client.js"
import { setWarning, removeMessages } from "../../messages"
import AgreementsList from "./AgreementsList.vue";
import { APIClient } from "../../fetch/api-client.js";
import { setWarning, removeMessages } from "../../messages";
export default {
data() {},
beforeCreate() {},
methods: {
serializeAgreement() {
let erm_package = JSON.parse(JSON.stringify(this.erm_package)) // copy
delete erm_package.vendor_id // This is the EBSCO's vendor_id
let erm_package = JSON.parse(JSON.stringify(this.erm_package)); // copy
delete erm_package.vendor_id; // This is the EBSCO's vendor_id
// Remove remote data, we don't need to store them (don't we?)
// Keep the name, it's mandatory by the REST API specs
delete erm_package.package_type
delete erm_package.content_type
erm_package.external_id = erm_package.package_id
delete erm_package.package_id
erm_package.provider = "ebsco"
erm_package.package_id = erm_package.koha_internal_id
delete erm_package.koha_internal_id
delete erm_package.resources
delete erm_package.vendor
delete erm_package.resources_count
delete erm_package.is_selected
delete erm_package.package_type;
delete erm_package.content_type;
erm_package.external_id = erm_package.package_id;
delete erm_package.package_id;
erm_package.provider = "ebsco";
erm_package.package_id = erm_package.koha_internal_id;
delete erm_package.koha_internal_id;
delete erm_package.resources;
delete erm_package.vendor;
delete erm_package.resources_count;
delete erm_package.is_selected;
erm_package.package_agreements = erm_package.package_agreements.map(
({ package_id, agreement, ...keepAttrs }) => keepAttrs
)
return erm_package
);
return erm_package;
},
showAddAgreementModal() {
$("#add_agreement").modal("show")
$("#add_agreement").modal("show");
},
addAgreement(agreement_id) {
removeMessages()
$("#add_agreement").modal("hide")
let erm_package = this.serializeAgreement()
removeMessages();
$("#add_agreement").modal("hide");
let erm_package = this.serializeAgreement();
// Only add if it does not exist
if (
!erm_package.package_agreements.find(
a => a.agreement_id == agreement_id
)
) {
erm_package.package_agreements.push({ agreement_id })
const client = APIClient.erm
erm_package.package_agreements.push({ agreement_id });
const client = APIClient.erm;
if (this.erm_package.koha_internal_id) {
let package_id = erm_package.package_id
delete erm_package.package_id
let package_id = erm_package.package_id;
delete erm_package.package_id;
client.localPackages.update(erm_package, package_id).then(
success => {
this.$emit("refresh-agreements")
this.$emit("refresh-agreements");
},
error => {}
)
);
} else {
client.localPackages.create(erm_package).then(
success => {
this.$emit("refresh-agreements")
this.$emit("refresh-agreements");
},
error => {}
)
);
}
} else {
setWarning(
this.$__(
"This agreement is already linked with this package"
)
)
);
}
},
deleteAgreement(counter) {
let erm_package = this.serializeAgreement()
erm_package.package_agreements.splice(counter, 1)
let package_id = erm_package.package_id
delete erm_package.package_id
const client = APIClient.erm
let erm_package = this.serializeAgreement();
erm_package.package_agreements.splice(counter, 1);
let package_id = erm_package.package_id;
delete erm_package.package_id;
const client = APIClient.erm;
client.localPackages.update(erm_package, package_id).then(
success => {
this.$emit("refresh-agreements")
this.$emit("refresh-agreements");
},
error => {}
)
);
},
},
props: {
@ -161,7 +161,7 @@ export default {
},
emits: ["refresh-agreements"],
name: "EHoldingsEBSCOPackageAgreements",
}
};
</script>
<style>
#add_agreement #agreements_list table {

View File

@ -60,22 +60,22 @@
</template>
<script>
import { inject, ref, reactive } from "vue"
import { storeToRefs } from "pinia"
import KohaTable from "../KohaTable.vue"
import { inject, ref, reactive } from "vue";
import { storeToRefs } from "pinia";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const AVStore = inject("AVStore")
const { av_title_publication_types } = storeToRefs(AVStore)
const { get_lib_from_av, map_av_dt_filter } = AVStore
const AVStore = inject("AVStore");
const { av_title_publication_types } = storeToRefs(AVStore);
const { get_lib_from_av, map_av_dt_filter } = AVStore;
const table = ref()
const table = ref();
const filters = reactive({
publication_title: "",
publication_type: "",
selection_type: "",
})
});
return {
av_title_publication_types,
@ -83,15 +83,15 @@ export default {
escape_str,
map_av_dt_filter,
table,
}
};
},
data() {
this.filters = {
publication_title: this.$route.query.publication_title || "",
publication_type: this.$route.query.publication_type || "",
selection_type: this.$route.query.selection_type || "",
}
let filters = this.filters
};
let filters = this.filters;
return {
tableOptions: {
columns: this.getTableColumns(),
@ -115,40 +115,40 @@ export default {
actions: { 0: ["show"] },
default_filters: {
publication_title: function () {
return filters.publication_title || ""
return filters.publication_title || "";
},
publication_type: function () {
return filters.publication_type || ""
return filters.publication_type || "";
},
selection_type: function () {
return filters.selection_type || ""
return filters.selection_type || "";
},
},
},
display_filters: false,
}
};
},
methods: {
doShow: function ({ resource_id }, dt, event) {
event.preventDefault()
event.preventDefault();
this.$router.push({
name: "EHoldingsEBSCOResourcesShow",
params: { resource_id },
})
});
},
filter_table: function () {
this.$refs.table.redraw(
"/api/v1/erm/eholdings/ebsco/packages/" +
this.package_id +
"/resources"
)
);
},
toggle_filters: function (e) {
this.display_filters = !this.display_filters
this.display_filters = !this.display_filters;
},
getTableColumns: function () {
let get_lib_from_av = this.get_lib_from_av
let map_av_dt_filter = this.map_av_dt_filter
let get_lib_from_av = this.get_lib_from_av;
let map_av_dt_filter = this.map_av_dt_filter;
return [
{
@ -162,15 +162,15 @@ export default {
row.resource_id +
'" class="show">' +
escape_str(`${row.title.publication_title}`) +
"</a>"
"</a>";
if (row.is_selected) {
node +=
" " +
'<i class="fa fa-check-square" style="color: green; float: right;" title="' +
__("Is selected") +
'" />'
'" />';
}
return node
return node;
},
},
{
@ -184,10 +184,10 @@ export default {
"av_title_publication_types",
row.title.publication_type
)
)
);
},
},
]
];
},
},
props: {
@ -195,7 +195,7 @@ export default {
},
components: { KohaTable },
name: "EHoldingsEBSCOPackageTitlesList",
}
};
</script>
<style scoped>

View File

@ -65,28 +65,28 @@
</template>
<script>
import { inject, ref, reactive } from "vue"
import { storeToRefs } from "pinia"
import { APIClient } from "../../fetch/api-client.js"
import { build_url_params, build_url } from "../../composables/datatables"
import KohaTable from "../KohaTable.vue"
import { inject, ref, reactive } from "vue";
import { storeToRefs } from "pinia";
import { APIClient } from "../../fetch/api-client.js";
import { build_url_params, build_url } from "../../composables/datatables";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const AVStore = inject("AVStore")
const AVStore = inject("AVStore");
const { av_package_types, av_package_content_types } =
storeToRefs(AVStore)
const { get_lib_from_av, map_av_dt_filter } = AVStore
storeToRefs(AVStore);
const { get_lib_from_av, map_av_dt_filter } = AVStore;
const ERMStore = inject("ERMStore")
const { config } = ERMStore
const ERMStore = inject("ERMStore");
const { config } = ERMStore;
const table = ref()
const table = ref();
const filters = reactive({
package_name: "",
content_type: "",
selection_type: "",
})
});
return {
av_package_types,
@ -96,15 +96,15 @@ export default {
map_av_dt_filter,
config,
table,
}
};
},
data: function () {
this.filters = {
package_name: this.$route.query.package_name || "",
content_type: this.$route.query.content_type || "",
selection_type: this.$route.query.selection_type || "",
}
let filters = this.filters
};
let filters = this.filters;
return {
packages: [],
@ -125,47 +125,47 @@ export default {
actions: { 0: ["show"] },
default_filters: {
name: function () {
return filters.package_name || ""
return filters.package_name || "";
},
content_type: function () {
return filters.content_type || ""
return filters.content_type || "";
},
selection_type: function () {
return filters.selection_type || ""
return filters.selection_type || "";
},
},
},
show_table: build_url_params(filters).length ? true : false,
local_count_packages: null,
}
};
},
computed: {
local_packages_url() {
let { href } = this.$router.resolve({
name: "EHoldingsLocalPackagesList",
})
return build_url(href, this.filters)
});
return build_url(href, this.filters);
},
},
methods: {
doShow: function ({ package_id }, dt, event) {
event.preventDefault()
event.preventDefault();
this.$router.push({
name: "EHoldingsEBSCOPackagesShow",
params: { package_id },
})
});
},
filter_table: async function () {
let { href } = this.$router.resolve({
name: "EHoldingsEBSCOPackagesList",
})
let new_route = build_url(href, this.filters)
this.$router.push(new_route)
this.show_table = true
this.local_count_packages = null
});
let new_route = build_url(href, this.filters);
this.$router.push(new_route);
this.show_table = true;
this.local_count_packages = null;
if (this.config.settings.ERMProviders.includes("local")) {
const client = APIClient.erm
const client = APIClient.erm;
const query = this.filters
? {
"me.name": {
@ -175,20 +175,20 @@ export default {
? { "me.content_type": this.filters.content_type }
: {}),
}
: {}
: {};
client.localPackages.count(query).then(
count => (this.local_count_packages = count),
error => {}
)
);
}
if (this.$refs.table) {
this.$refs.table.redraw("/api/v1/erm/eholdings/ebsco/packages")
this.$refs.table.redraw("/api/v1/erm/eholdings/ebsco/packages");
}
},
getTableColumns: function () {
let get_lib_from_av = this.get_lib_from_av
let escape_str = this.escape_str
let get_lib_from_av = this.get_lib_from_av;
let escape_str = this.escape_str;
return [
{
@ -202,15 +202,15 @@ export default {
row.package_id +
'" class="show">' +
escape_str(`${row.name} (#${row.package_id})`) +
"</a>"
"</a>";
if (row.is_selected) {
node +=
" " +
'<i class="fa fa-check-square" style="color: green; float: right;" title="' +
__("Is selected") +
'" />'
'" />';
}
return node
return node;
},
},
{
@ -219,7 +219,7 @@ export default {
searchable: false,
orderable: false,
render: function (data, type, row, meta) {
return row.vendor ? escape_str(row.vendor.name) : ""
return row.vendor ? escape_str(row.vendor.name) : "";
},
},
{
@ -233,7 +233,7 @@ export default {
"av_package_types",
row.package_type
)
)
);
},
},
{
@ -246,13 +246,13 @@ export default {
"av_package_content_types",
row.content_type
)
)
);
},
},
]
];
},
},
components: { KohaTable },
name: "EHoldingsEBSCOPackagesList",
}
};
</script>

View File

@ -113,22 +113,22 @@
</template>
<script>
import { inject } from "vue"
import EHoldingsPackageAgreements from "./EHoldingsEBSCOPackageAgreements.vue"
import EHoldingsPackageTitlesList from "./EHoldingsEBSCOPackageTitlesList.vue"
import { APIClient } from "../../fetch/api-client.js"
import { inject } from "vue";
import EHoldingsPackageAgreements from "./EHoldingsEBSCOPackageAgreements.vue";
import EHoldingsPackageTitlesList from "./EHoldingsEBSCOPackageTitlesList.vue";
import { APIClient } from "../../fetch/api-client.js";
export default {
setup() {
const format_date = $date
const format_date = $date;
const AVStore = inject("AVStore")
const { get_lib_from_av } = AVStore
const AVStore = inject("AVStore");
const { get_lib_from_av } = AVStore;
return {
format_date,
get_lib_from_av,
}
};
},
data() {
return {
@ -146,51 +146,51 @@ export default {
},
initialized: false,
updating_is_selected: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getPackage(to.params.package_id)
})
vm.getPackage(to.params.package_id);
});
},
beforeRouteUpdate(to, from) {
this.erm_package = this.getPackage(to.params.package_id)
this.erm_package = this.getPackage(to.params.package_id);
},
methods: {
getPackage(package_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.EBSCOPackages.get(package_id).then(
erm_package => {
this.erm_package = erm_package
this.initialized = true
this.updating_is_selected = false
this.erm_package = erm_package;
this.initialized = true;
this.updating_is_selected = false;
},
error => {}
)
);
},
edit_selected(is_selected) {
this.updating_is_selected = true
const client = APIClient.erm
this.updating_is_selected = true;
const client = APIClient.erm;
client.EBSCOPackages.patch(this.erm_package.package_id, {
is_selected,
}).then(
result => {
// Refresh the page. We should not need that actually.
this.getPackage(this.erm_package.package_id)
this.getPackage(this.erm_package.package_id);
},
error => {}
)
);
},
add_to_holdings() {
this.edit_selected(true)
this.edit_selected(true);
},
remove_from_holdings() {
this.edit_selected(false)
this.edit_selected(false);
},
refreshAgreements() {
// FIXME We could GET /erm/eholdings/packages/$package_id/agreements instead
this.initialized = false
this.getPackage(this.erm_package.package_id)
this.initialized = false;
this.getPackage(this.erm_package.package_id);
},
},
components: {
@ -198,7 +198,7 @@ export default {
EHoldingsPackageTitlesList,
},
name: "EHoldingsEBSCOPackagesShow",
}
};
</script>
<style scoped>
fieldset.rows label {

View File

@ -120,17 +120,17 @@
</template>
<script>
import { inject } from "vue"
import { storeToRefs } from "pinia"
import { APIClient } from "../../fetch/api-client.js"
import { inject } from "vue";
import { storeToRefs } from "pinia";
import { APIClient } from "../../fetch/api-client.js";
export default {
setup() {
const format_date = $date
const format_date = $date;
return {
format_date,
}
};
},
data() {
return {
@ -146,51 +146,51 @@ export default {
},
initialized: false,
updating_is_selected: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getResource(to.params.resource_id)
})
vm.getResource(to.params.resource_id);
});
},
beforeRouteUpdate(to, from) {
this.resource = this.getResource(to.params.resource_id)
this.resource = this.getResource(to.params.resource_id);
},
methods: {
getResource(resource_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.EBSCOResources.get(resource_id).then(
resource => {
this.resource = resource
this.initialized = true
this.updating_is_selected = false
this.resource = resource;
this.initialized = true;
this.updating_is_selected = false;
},
error => {}
)
);
},
edit_selected(is_selected) {
this.updating_is_selected = true
const client = APIClient.erm
this.updating_is_selected = true;
const client = APIClient.erm;
client.EBSCOResources.patch(this.resource.resource_id, {
is_selected,
}).then(
result => {
// Refresh the page. We should not need that actually.
this.getResource(this.resource.resource_id)
this.getResource(this.resource.resource_id);
},
error => {}
)
);
},
add_to_holdings() {
this.edit_selected(true)
this.edit_selected(true);
},
remove_from_holdings() {
this.edit_selected(false)
this.edit_selected(false);
},
},
name: "EHoldingsEBSCOResourcesShow",
}
};
</script>
<style scoped>
fieldset.rows label {

View File

@ -43,17 +43,17 @@
</template>
<script>
import { createVNode, render } from "vue"
import { useDataTable } from "../../composables/datatables"
import { createVNode, render } from "vue";
import { useDataTable } from "../../composables/datatables";
export default {
setup() {
const table_id = "package_list"
useDataTable(table_id)
const table_id = "package_list";
useDataTable(table_id);
return {
table_id,
}
};
},
data() {
return {
@ -62,33 +62,33 @@ export default {
selection_type: 0,
},
display_filters: false,
}
};
},
methods: {
show_resource: function (resource_id) {
this.$router.push({
name: "EHoldingsEBSCOResourcesShow",
params: { resource_id },
})
});
},
toggle_filters: function (e) {
this.display_filters = !this.display_filters
this.display_filters = !this.display_filters;
},
filter_table: function () {
$("#" + this.table_id)
.DataTable()
.draw()
.draw();
},
build_datatable: function () {
let show_resource = this.show_resource
let resources = this.resources
let filters = this.filters
let table_id = this.table_id
let router = this.$router
let show_resource = this.show_resource;
let resources = this.resources;
let filters = this.filters;
let table_id = this.table_id;
let router = this.$router;
$.fn.dataTable.ext.search = $.fn.dataTable.ext.search.filter(
search => search.name != "apply_filter"
)
);
$("#" + table_id).dataTable({
...dataTablesDefaults,
...{
@ -109,38 +109,38 @@ export default {
orderable: false,
render: function (data, type, row, meta) {
// Rendering done in drawCallback
return ""
return "";
},
width: "100%",
},
],
drawCallback: function (settings) {
var api = new $.fn.dataTable.Api(settings)
var api = new $.fn.dataTable.Api(settings);
if (!api.rows({ search: "applied" }).count()) return
if (!api.rows({ search: "applied" }).count()) return;
$.each(
$(this).find("tbody tr td:first-child"),
function (index, e) {
let tr = $(this).parent()
let row = api.row(tr).data()
if (!row) return // Happen if the table is empty
let tr = $(this).parent();
let row = api.row(tr).data();
if (!row) return; // Happen if the table is empty
let { href } = router.resolve({
name: "EHoldingsEBSCOResourcesShow",
params: { resource_id: row.resource_id },
})
});
let n = createVNode(
"a",
{
role: "button",
href,
onClick: e => {
e.preventDefault()
show_resource(row.resource_id)
e.preventDefault();
show_resource(row.resource_id);
},
},
`${row.package.name}`
)
);
if (row.is_selected) {
n = createVNode("span", {}, [
n,
@ -153,11 +153,11 @@ export default {
},
title: __("Is selected"),
}),
])
]);
}
render(n, e)
render(n, e);
}
)
);
},
initComplete: function () {
$.fn.dataTable.ext.search.push(
@ -176,22 +176,22 @@ export default {
row.is_selected) ||
(filters.selection_type == 2 &&
!row.is_selected))
)
);
}
)
);
},
},
})
});
},
},
mounted() {
this.build_datatable()
this.build_datatable();
},
props: {
resources: Array,
},
name: "EHoldingsEBSCOTitlePackagesList",
}
};
</script>
<style scoped>

View File

@ -69,27 +69,27 @@
</template>
<script>
import { inject, ref, reactive } from "vue"
import { storeToRefs } from "pinia"
import { APIClient } from "../../fetch/api-client.js"
import { build_url_params, build_url } from "../../composables/datatables"
import KohaTable from "../KohaTable.vue"
import { inject, ref, reactive } from "vue";
import { storeToRefs } from "pinia";
import { APIClient } from "../../fetch/api-client.js";
import { build_url_params, build_url } from "../../composables/datatables";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const AVStore = inject("AVStore")
const { av_title_publication_types } = storeToRefs(AVStore)
const { get_lib_from_av } = AVStore
const AVStore = inject("AVStore");
const { av_title_publication_types } = storeToRefs(AVStore);
const { get_lib_from_av } = AVStore;
const ERMStore = inject("ERMStore")
const { config } = ERMStore
const ERMStore = inject("ERMStore");
const { config } = ERMStore;
const table = ref()
const table = ref();
const filters = reactive({
publication_title: "",
publication_type: "",
selection_type: "",
})
});
return {
av_title_publication_types,
@ -97,15 +97,15 @@ export default {
escape_str,
config,
table,
}
};
},
data: function () {
this.filters = {
publication_title: this.$route.query.publication_title || "",
publication_type: this.$route.query.publication_type || "",
selection_type: this.$route.query.selection_type || "",
}
let filters = this.filters
};
let filters = this.filters;
return {
titles: [],
@ -128,55 +128,55 @@ export default {
actions: { 0: ["show"] },
default_filters: {
publication_title: function () {
return filters.publication_title || ""
return filters.publication_title || "";
},
publication_type: function () {
return filters.publication_type || ""
return filters.publication_type || "";
},
selection_type: function () {
return filters.selection_type || ""
return filters.selection_type || "";
},
},
},
cannot_search: false,
show_table: build_url_params(filters).length ? true : false,
local_title_count: null,
}
};
},
computed: {
local_titles_url() {
let { href } = this.$router.resolve({
name: "EHoldingsLocalTitlesList",
})
return build_url(href, this.filters)
});
return build_url(href, this.filters);
},
},
methods: {
doShow: function ({ title_id }, dt, event) {
event.preventDefault()
event.preventDefault();
this.$router.push({
name: "EHoldingsEBSCOTitlesShow",
params: { title_id },
})
});
},
filter_table: async function () {
if (this.filters.publication_title.length) {
this.cannot_search = false
this.cannot_search = false;
let { href } = this.$router.resolve({
name: "EHoldingsEBSCOTitlesList",
})
let new_route = build_url(href, this.filters)
this.$router.push(new_route)
this.show_table = true
this.local_title_count = null
});
let new_route = build_url(href, this.filters);
this.$router.push(new_route);
this.show_table = true;
this.local_title_count = null;
if (this.$refs.table) {
this.$refs.table.redraw(
"/api/v1/erm/eholdings/ebsco/titles"
)
);
}
if (this.config.settings.ERMProviders.includes("local")) {
const client = APIClient.erm
const client = APIClient.erm;
const q = this.filters
? {
@ -197,20 +197,20 @@ export default {
}
: {}),
}
: undefined
: undefined;
client.localTitles.count(q).then(
count => (this.local_title_count = count),
error => {}
)
);
}
} else {
this.cannot_search = true
this.cannot_search = true;
}
},
getTableColumns: function () {
let get_lib_from_av = this.get_lib_from_av
let escape_str = this.escape_str
let get_lib_from_av = this.get_lib_from_av;
let escape_str = this.escape_str;
return [
{
title: __("Title"),
@ -225,15 +225,15 @@ export default {
escape_str(
`${row.publication_title} (#${row.title_id})`
) +
"</a>"
"</a>";
if (row.is_selected) {
node +=
" " +
'<i class="fa fa-check-square" style="color: green; float: right;" title="' +
__("Is selected") +
'" />'
'" />';
}
return node
return node;
},
},
{
@ -242,7 +242,7 @@ export default {
searchable: false,
orderable: false,
render: function (data, type, row, meta) {
return escape_str(row.publisher_name)
return escape_str(row.publisher_name);
},
},
{
@ -256,7 +256,7 @@ export default {
"av_title_publication_types",
row.publication_type
)
)
);
},
},
{
@ -265,8 +265,8 @@ export default {
searchable: false,
orderable: false,
render: function (data, type, row, meta) {
let print_identifier = row.print_identifier
let online_identifier = row.online_identifier
let print_identifier = row.print_identifier;
let online_identifier = row.online_identifier;
return (
(print_identifier
? escape_str(
@ -282,13 +282,13 @@ export default {
)
)
: "")
)
);
},
},
]
];
},
},
components: { KohaTable },
name: "EHoldingsEBSCOTitlesList",
}
};
</script>

View File

@ -243,18 +243,18 @@
</template>
<script>
import { inject } from "vue"
import EHoldingsTitlePackagesList from "./EHoldingsEBSCOTitlePackagesList.vue"
import { APIClient } from "../../fetch/api-client.js"
import { inject } from "vue";
import EHoldingsTitlePackagesList from "./EHoldingsEBSCOTitlePackagesList.vue";
import { APIClient } from "../../fetch/api-client.js";
export default {
setup() {
const AVStore = inject("AVStore")
const { get_lib_from_av } = AVStore
const AVStore = inject("AVStore");
const { get_lib_from_av } = AVStore;
return {
get_lib_from_av,
}
};
},
data() {
return {
@ -288,33 +288,33 @@ export default {
resources: [],
},
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getTitle(to.params.title_id)
})
vm.getTitle(to.params.title_id);
});
},
beforeRouteUpdate(to, from) {
this.title = this.getTitle(to.params.title_id)
this.title = this.getTitle(to.params.title_id);
},
methods: {
getTitle(title_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.EBSCOTitles.get(title_id).then(
title => {
this.title = title
this.initialized = true
this.title = title;
this.initialized = true;
},
error => {}
)
);
},
},
components: {
EHoldingsTitlePackagesList,
},
name: "EHoldingsEBSCOTitlesShow",
}
};
</script>
<style scoped>
fieldset.rows label {

View File

@ -55,38 +55,38 @@
</template>
<script>
import { APIClient } from "../../fetch/api-client.js"
import { APIClient } from "../../fetch/api-client.js";
export default {
data() {
return {
agreements: [],
initialized: false,
}
};
},
beforeCreate() {
const client = APIClient.erm
const client = APIClient.erm;
client.agreements.getAll().then(
agreements => {
this.agreements = agreements
this.initialized = true
this.agreements = agreements;
this.initialized = true;
},
error => {}
)
);
},
methods: {
addAgreement() {
this.package_agreements.push({
agreement_id: null,
})
});
},
deleteAgreement(counter) {
this.package_agreements.splice(counter, 1)
this.package_agreements.splice(counter, 1);
},
},
props: {
package_agreements: Array,
},
name: "EHoldingsLocalPackageAgreements",
}
};
</script>

View File

@ -5,21 +5,21 @@
</template>
<script>
import { inject, ref } from "vue"
import KohaTable from "../KohaTable.vue"
import { inject, ref } from "vue";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const AVStore = inject("AVStore")
const { get_lib_from_av, map_av_dt_filter } = AVStore
const AVStore = inject("AVStore");
const { get_lib_from_av, map_av_dt_filter } = AVStore;
const table = ref()
const table = ref();
return {
get_lib_from_av,
map_av_dt_filter,
escape_str,
table,
}
};
},
data() {
return {
@ -39,19 +39,19 @@ export default {
0: ["show"],
},
},
}
};
},
methods: {
doShow: function ({ resource_id }, dt, event) {
event.preventDefault()
event.preventDefault();
this.$router.push({
name: "EHoldingsLocalResourcesShow",
params: { resource_id },
})
});
},
getTableColumns: function () {
let get_lib_from_av = this.get_lib_from_av
let escape_str = this.escape_str
let get_lib_from_av = this.get_lib_from_av;
let escape_str = this.escape_str;
return [
{
@ -66,7 +66,7 @@ export default {
'" class="show">' +
escape_str(row.title.publication_title) +
"</a>"
)
);
},
},
{
@ -80,10 +80,10 @@ export default {
"av_title_publication_types",
row.title.publication_type
)
)
);
},
},
]
];
},
},
props: {
@ -91,5 +91,5 @@ export default {
},
components: { KohaTable },
name: "EHoldingsLocalPackageTitlesList",
}
};
</script>

View File

@ -90,24 +90,24 @@
</template>
<script>
import { inject } from "vue"
import EHoldingsPackageAgreements from "./EHoldingsLocalPackageAgreements.vue"
import AdditionalFieldsEntry from "../AdditionalFieldsEntry.vue"
import FormSelectVendors from "../FormSelectVendors.vue"
import { setMessage, setError, setWarning } from "../../messages"
import { APIClient } from "../../fetch/api-client.js"
import { storeToRefs } from "pinia"
import { inject } from "vue";
import EHoldingsPackageAgreements from "./EHoldingsLocalPackageAgreements.vue";
import AdditionalFieldsEntry from "../AdditionalFieldsEntry.vue";
import FormSelectVendors from "../FormSelectVendors.vue";
import { setMessage, setError, setWarning } from "../../messages";
import { APIClient } from "../../fetch/api-client.js";
import { storeToRefs } from "pinia";
export default {
setup() {
const AVStore = inject("AVStore")
const AVStore = inject("AVStore");
const { av_package_types, av_package_content_types } =
storeToRefs(AVStore)
storeToRefs(AVStore);
return {
av_package_types,
av_package_content_types,
}
};
},
data() {
return {
@ -125,91 +125,91 @@ export default {
extended_attributes: [],
},
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (to.params.package_id) {
vm.erm_package = vm.getPackage(to.params.package_id)
vm.erm_package = vm.getPackage(to.params.package_id);
} else {
vm.initialized = true
vm.initialized = true;
}
})
});
},
methods: {
getPackage(package_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.localPackages.get(package_id).then(
erm_package => {
this.erm_package = erm_package
this.initialized = true
this.erm_package = erm_package;
this.initialized = true;
},
error => {}
)
);
},
checkForm(erm_package) {
let errors = []
let package_agreements = erm_package.package_agreements
const agreement_ids = package_agreements.map(pa => pa.agreement_id)
let errors = [];
let package_agreements = erm_package.package_agreements;
const agreement_ids = package_agreements.map(pa => pa.agreement_id);
const duplicate_agreement_ids = agreement_ids.filter(
(id, i) => agreement_ids.indexOf(id) !== i
)
);
if (duplicate_agreement_ids.length) {
errors.push(this.$__("An agreement is used several times"))
errors.push(this.$__("An agreement is used several times"));
}
errors.forEach(function (e) {
setWarning(e)
})
return !errors.length
setWarning(e);
});
return !errors.length;
},
onSubmit(e) {
e.preventDefault()
e.preventDefault();
let erm_package = JSON.parse(JSON.stringify(this.erm_package)) // copy
let erm_package = JSON.parse(JSON.stringify(this.erm_package)); // copy
if (!this.checkForm(erm_package)) {
return false
return false;
}
let package_id = erm_package.package_id
delete erm_package.package_id
delete erm_package.resources
delete erm_package.vendor
delete erm_package.resources_count
delete erm_package.is_selected
delete erm_package._strings
let package_id = erm_package.package_id;
delete erm_package.package_id;
delete erm_package.resources;
delete erm_package.vendor;
delete erm_package.resources_count;
delete erm_package.is_selected;
delete erm_package._strings;
erm_package.package_agreements = erm_package.package_agreements.map(
({ package_id, agreement, ...keepAttrs }) => keepAttrs
)
);
const client = APIClient.erm
const client = APIClient.erm;
if (package_id) {
client.localPackages.update(erm_package, package_id).then(
success => {
setMessage(this.$__("Package updated"))
setMessage(this.$__("Package updated"));
this.$router.push({
name: "EHoldingsLocalPackagesList",
})
});
},
error => {}
)
);
} else {
client.localPackages.create(erm_package).then(
success => {
setMessage(this.$__("Package created"))
setMessage(this.$__("Package created"));
this.$router.push({
name: "EHoldingsLocalPackagesList",
})
});
},
error => {}
)
);
}
},
additionalFieldsChanged(additionalFieldValues) {
this.erm_package.extended_attributes = additionalFieldValues
this.erm_package.extended_attributes = additionalFieldValues;
},
},
components: {
@ -218,5 +218,5 @@ export default {
AdditionalFieldsEntry,
},
name: "EHoldingsEBSCOPackagesFormAdd",
}
};
</script>

View File

@ -32,28 +32,28 @@
</template>
<script>
import Toolbar from "../Toolbar.vue"
import ToolbarButton from "../ToolbarButton.vue"
import { inject, ref, reactive } from "vue"
import { storeToRefs } from "pinia"
import { APIClient } from "../../fetch/api-client.js"
import KohaTable from "../KohaTable.vue"
import Toolbar from "../Toolbar.vue";
import ToolbarButton from "../ToolbarButton.vue";
import { inject, ref, reactive } from "vue";
import { storeToRefs } from "pinia";
import { APIClient } from "../../fetch/api-client.js";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const vendorStore = inject("vendorStore")
const { vendors } = storeToRefs(vendorStore)
const vendorStore = inject("vendorStore");
const { vendors } = storeToRefs(vendorStore);
const AVStore = inject("AVStore")
const { get_lib_from_av, map_av_dt_filter } = AVStore
const AVStore = inject("AVStore");
const { get_lib_from_av, map_av_dt_filter } = AVStore;
const { setConfirmationDialog, setMessage } = inject("mainStore")
const { setConfirmationDialog, setMessage } = inject("mainStore");
const table = ref()
const table = ref();
const filters = reactive({
package_name: "",
content_type: "",
})
});
return {
vendors,
@ -65,14 +65,14 @@ export default {
setMessage,
escape_str,
eholdings_packages_table_settings,
}
};
},
data: function () {
this.filters = {
package_name: this.$route.query.package_name || "",
content_type: this.$route.query.content_type || "",
}
let filters = this.filters
};
let filters = this.filters;
return {
package_count: 0,
initialized: false,
@ -97,9 +97,9 @@ export default {
filters_options: {
1: () =>
this.vendors.map(e => {
e["_id"] = e["id"]
e["_str"] = e["name"]
return e
e["_id"] = e["id"];
e["_str"] = e["name"];
return e;
}),
2: () => this.map_av_dt_filter("av_package_types"),
3: () => this.map_av_dt_filter("av_package_content_types"),
@ -109,7 +109,7 @@ export default {
"-1": ["edit", "delete"],
},
},
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
@ -121,36 +121,36 @@ export default {
.getSearchableAVOptions()
.then(() => (vm.initialized = true))
)
)
})
);
});
},
methods: {
async getPackageCount() {
const client = APIClient.erm
const client = APIClient.erm;
await client.localPackages.count().then(
count => {
this.package_count = count
this.package_count = count;
},
error => {}
)
);
},
async getSearchableAdditionalFields() {
const client = APIClient.additional_fields
const client = APIClient.additional_fields;
await client.additional_fields.getAll("package").then(
searchable_additional_fields => {
this.searchable_additional_fields =
searchable_additional_fields.filter(
field => field.searchable
)
);
},
error => {}
)
);
},
async getSearchableAVOptions() {
const client_av = APIClient.authorised_values
const client_av = APIClient.authorised_values;
let av_cat_array = this.searchable_additional_fields
.filter(field => field.authorised_value_category_name)
.map(field => field.authorised_value_category_name)
.map(field => field.authorised_value_category_name);
await client_av.values
.getCategoriesWithValues([
@ -160,27 +160,27 @@ export default {
av_cat_array.forEach(av_cat => {
let av_match = av_categories.find(
element => element.category_name == av_cat
)
);
this.searchable_av_options[av_cat] =
av_match.authorised_values.map(av => ({
value: av.value,
label: av.description,
}))
})
})
}));
});
});
},
doShow: function ({ package_id }, dt, event) {
event.preventDefault()
event.preventDefault();
this.$router.push({
name: "EHoldingsLocalPackagesShow",
params: { package_id },
})
});
},
doEdit: function ({ package_id }, dt, event) {
this.$router.push({
name: "EHoldingsLocalPackagesFormAddEdit",
params: { package_id },
})
});
},
doDelete: function (erm_package, dt, event) {
this.setConfirmationDialog(
@ -193,7 +193,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
const client = APIClient.erm;
client.localPackages.delete(erm_package.package_id).then(
success => {
this.setMessage(
@ -201,17 +201,17 @@ export default {
erm_package.name
),
true
)
dt.draw()
);
dt.draw();
},
error => {}
)
);
}
)
);
},
getTableColumns: function () {
let get_lib_from_av = this.get_lib_from_av
let escape_str = this.escape_str
let get_lib_from_av = this.get_lib_from_av;
let escape_str = this.escape_str;
return [
{
title: __("Name"),
@ -225,7 +225,7 @@ export default {
'" class="show">' +
escape_str(`${row.name} (#${row.package_id})`) +
"</a>"
)
);
},
},
{
@ -240,7 +240,7 @@ export default {
'">' +
escape_str(row.vendor.name) +
"</a>"
: ""
: "";
},
},
{
@ -254,7 +254,7 @@ export default {
"av_package_types",
row.package_type
)
)
);
},
},
{
@ -268,7 +268,7 @@ export default {
"av_package_content_types",
row.content_type
)
)
);
},
},
{
@ -277,7 +277,7 @@ export default {
searchable: false,
orderable: true,
render: function (data, type, row, meta) {
return $date(row.created_on)
return $date(row.created_on);
},
},
{
@ -286,13 +286,13 @@ export default {
searchable: true,
orderable: true,
render: function (data, type, row, meta) {
return row.notes
return row.notes;
},
},
]
];
},
},
components: { Toolbar, ToolbarButton, KohaTable },
name: "EHoldingsLocalPackagesList",
}
};
</script>

View File

@ -120,28 +120,28 @@
</template>
<script>
import { inject } from "vue"
import EHoldingsPackageTitlesList from "./EHoldingsLocalPackageTitlesList.vue"
import { APIClient } from "../../fetch/api-client.js"
import Toolbar from "../Toolbar.vue"
import ToolbarButton from "../ToolbarButton.vue"
import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue"
import { inject } from "vue";
import EHoldingsPackageTitlesList from "./EHoldingsLocalPackageTitlesList.vue";
import { APIClient } from "../../fetch/api-client.js";
import Toolbar from "../Toolbar.vue";
import ToolbarButton from "../ToolbarButton.vue";
import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue";
export default {
setup() {
const format_date = $date
const format_date = $date;
const { setConfirmationDialog, setMessage } = inject("mainStore")
const { setConfirmationDialog, setMessage } = inject("mainStore");
const AVStore = inject("AVStore")
const { get_lib_from_av } = AVStore
const AVStore = inject("AVStore");
const { get_lib_from_av } = AVStore;
return {
format_date,
get_lib_from_av,
setConfirmationDialog,
setMessage,
}
};
},
data() {
return {
@ -159,26 +159,26 @@ export default {
_strings: [],
},
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getPackage(to.params.package_id)
})
vm.getPackage(to.params.package_id);
});
},
beforeRouteUpdate(to, from) {
this.erm_package = this.getPackage(to.params.package_id)
this.erm_package = this.getPackage(to.params.package_id);
},
methods: {
getPackage(package_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.localPackages.get(package_id).then(
erm_package => {
this.erm_package = erm_package
this.initialized = true
this.erm_package = erm_package;
this.initialized = true;
},
error => {}
)
);
},
delete_package: function (package_id, package_name) {
this.setConfirmationDialog(
@ -191,7 +191,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
const client = APIClient.erm;
client.localPackages.delete(package_id).then(
success => {
this.setMessage(
@ -199,15 +199,15 @@ export default {
package_name
),
true
)
);
this.$router.push({
name: "EHoldingsLocalPackagesList",
})
});
},
error => {}
)
);
}
)
);
},
},
components: {
@ -217,7 +217,7 @@ export default {
AdditionalFieldsDisplay,
},
name: "EHoldingsLocalPackagesShow",
}
};
</script>
<style scoped>
fieldset.rows label {

View File

@ -101,16 +101,16 @@
</template>
<script>
import { inject } from "vue"
import { APIClient } from "../../fetch/api-client.js"
import { storeToRefs } from "pinia"
import { inject } from "vue";
import { APIClient } from "../../fetch/api-client.js";
import { storeToRefs } from "pinia";
export default {
setup() {
const format_date = $date
const format_date = $date;
return {
format_date,
}
};
},
data() {
return {
@ -125,31 +125,31 @@ export default {
package: {},
},
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getResource(to.params.resource_id)
})
vm.getResource(to.params.resource_id);
});
},
beforeRouteUpdate(to, from) {
this.resource = this.getResource(to.params.resource_id)
this.resource = this.getResource(to.params.resource_id);
},
methods: {
getResource(resource_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.localResources.get(resource_id).then(
resource => {
this.resource = resource
this.initialized = true
this.resource = resource;
this.initialized = true;
},
error => {}
)
);
},
},
name: "EHoldingsLocalResourcesShow",
}
};
</script>
<style scoped>
fieldset.rows label {

View File

@ -5,33 +5,33 @@
</template>
<script>
import { createVNode, render } from "vue"
import { useDataTable } from "../../composables/datatables"
import { createVNode, render } from "vue";
import { useDataTable } from "../../composables/datatables";
export default {
setup() {
const table_id = "package_list"
useDataTable(table_id)
const table_id = "package_list";
useDataTable(table_id);
return {
table_id,
}
};
},
data() {
return {}
return {};
},
methods: {
show_resource: function (resource_id) {
this.$router.push({
name: "EHoldingsLocalResourcesShow",
params: { resource_id },
})
});
},
build_datatable: function () {
let show_resource = this.show_resource
let router = this.$router
let resources = this.resources
let table_id = this.table_id
let show_resource = this.show_resource;
let router = this.$router;
let resources = this.resources;
let table_id = this.table_id;
$("#" + table_id).dataTable(
$.extend(true, {}, dataTablesDefaults, {
@ -47,52 +47,52 @@ export default {
orderable: true,
render: function (data, type, row, meta) {
// Rendering done in drawCallback
return ""
return "";
},
width: "100%",
},
],
drawCallback: function (settings) {
var api = new $.fn.dataTable.Api(settings)
var api = new $.fn.dataTable.Api(settings);
$.each(
$(this).find("tbody tr td:first-child"),
function (index, e) {
let tr = $(this).parent()
let row = api.row(tr).data()
if (!row) return // Happen if the table is empty
let tr = $(this).parent();
let row = api.row(tr).data();
if (!row) return; // Happen if the table is empty
let { href } = router.resolve({
name: "EHoldingsLocalResourcesShow",
params: { resource_id: row.resource_id },
})
});
let n = createVNode(
"a",
{
role: "button",
href,
onClick: e => {
e.preventDefault()
show_resource(row.resource_id)
e.preventDefault();
show_resource(row.resource_id);
},
},
`${row.package.name}`
)
render(n, e)
);
render(n, e);
}
)
);
},
})
)
);
},
},
mounted() {
this.build_datatable()
this.build_datatable();
},
props: {
resources: Array,
},
name: "EHoldingsLocalTitlePackagesList",
}
};
</script>
<style scoped>

View File

@ -412,22 +412,22 @@
</template>
<script>
import { inject } from "vue"
import EHoldingsTitlesFormAddResources from "./EHoldingsLocalTitlesFormAddResources.vue"
import { setMessage, setError, setWarning } from "../../messages"
import { APIClient } from "../../fetch/api-client.js"
import { storeToRefs } from "pinia"
import { inject } from "vue";
import EHoldingsTitlesFormAddResources from "./EHoldingsLocalTitlesFormAddResources.vue";
import { setMessage, setError, setWarning } from "../../messages";
import { APIClient } from "../../fetch/api-client.js";
import { storeToRefs } from "pinia";
export default {
setup() {
const AVStore = inject("AVStore")
const { av_title_publication_types } = storeToRefs(AVStore)
const { get_lib_from_av } = AVStore
const AVStore = inject("AVStore");
const { av_title_publication_types } = storeToRefs(AVStore);
const { get_lib_from_av } = AVStore;
return {
av_title_publication_types,
get_lib_from_av,
}
};
},
data() {
return {
@ -462,92 +462,92 @@ export default {
create_linked_biblio: false,
},
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (to.params.title_id) {
vm.title = vm.getTitle(to.params.title_id)
vm.title = vm.getTitle(to.params.title_id);
} else {
vm.initialized = true
vm.initialized = true;
}
})
});
},
methods: {
getTitle(title_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.localTitles.get(title_id).then(
title => {
this.title = title
this.initialized = true
this.title = title;
this.initialized = true;
},
error => {}
)
);
},
checkForm(title) {
let errors = []
let errors = [];
let resources = title.resources
const package_ids = resources.map(al => al.package_id)
let resources = title.resources;
const package_ids = resources.map(al => al.package_id);
const duplicate_package_ids = package_ids.filter(
(id, i) => package_ids.indexOf(id) !== i
)
);
if (duplicate_package_ids.length) {
errors.push(this.$__("A package is used several times"))
errors.push(this.$__("A package is used several times"));
}
errors.forEach(function (e) {
setWarning(e)
})
return !errors.length
setWarning(e);
});
return !errors.length;
},
onSubmit(e) {
e.preventDefault()
e.preventDefault();
let title = JSON.parse(JSON.stringify(this.title)) // copy
let title = JSON.parse(JSON.stringify(this.title)); // copy
if (!this.checkForm(title)) {
return false
return false;
}
let title_id = title.title_id
delete title.title_id
delete title.biblio_id
let title_id = title.title_id;
delete title.title_id;
delete title.biblio_id;
// Cannot use the map/keepAttrs because of the reserved keywork 'package'
title.resources.forEach(function (e) {
delete e.package
delete e.resource_id
})
delete e.package;
delete e.resource_id;
});
const client = APIClient.erm
const client = APIClient.erm;
if (title_id) {
client.localTitles.update(title, title_id).then(
success => {
setMessage(this.$__("Title updated"))
setMessage(this.$__("Title updated"));
this.$router.push({
name: "EHoldingsLocalTitlesList",
})
});
},
error => {}
)
);
} else {
client.localTitles.create(title).then(
success => {
setMessage(this.$__("Title created"))
setMessage(this.$__("Title created"));
this.$router.push({
name: "EHoldingsLocalTitlesList",
})
});
},
error => {}
)
);
}
},
},
components: { EHoldingsTitlesFormAddResources },
name: "EHoldingsLocalTitlesFormAdd",
}
};
</script>
<style scoped>
fieldset.rows label {

View File

@ -89,9 +89,9 @@
</template>
<script>
import flatPickr from "vue-flatpickr-component"
import { APIClient } from "../../fetch/api-client.js"
import FormSelectVendors from "../FormSelectVendors.vue"
import flatPickr from "vue-flatpickr-component";
import { APIClient } from "../../fetch/api-client.js";
import FormSelectVendors from "../FormSelectVendors.vue";
export default {
setup() {},
@ -99,17 +99,17 @@ export default {
return {
packages: [],
fp_config: flatpickr_defaults,
}
};
},
beforeCreate() {
const client = APIClient.erm
const client = APIClient.erm;
client.localPackages.getAll().then(
packages => {
this.packages = packages
this.initialized = true
this.packages = packages;
this.initialized = true;
},
error => {}
)
);
},
methods: {
addPackage() {
@ -119,10 +119,10 @@ export default {
started_on: null,
ended_on: null,
proxy: "",
})
});
},
deletePackage(counter) {
this.resources.splice(counter, 1)
this.resources.splice(counter, 1);
},
},
props: {
@ -130,5 +130,5 @@ export default {
},
components: { flatPickr, FormSelectVendors },
name: "EHoldingsLocalTitlesFormAddResources",
}
};
</script>

View File

@ -26,62 +26,62 @@
</template>
<script>
import { setError } from "../../messages"
import { createVNode, render } from "vue"
import { APIClient } from "../../fetch/api-client.js"
import { useDataTable } from "../../composables/datatables"
import { setError } from "../../messages";
import { createVNode, render } from "vue";
import { APIClient } from "../../fetch/api-client.js";
import { useDataTable } from "../../composables/datatables";
export default {
setup() {
const table_id = "list_list"
useDataTable(table_id)
const table_id = "list_list";
useDataTable(table_id);
return {
table_id,
logged_in_user_lists,
}
};
},
data() {
return {
job_id: null,
package_id: null,
packages: [],
}
};
},
beforeCreate() {
const client = APIClient.erm
const client = APIClient.erm;
client.localPackages.getAll().then(
packages => {
this.packages = packages
this.packages = packages;
if (this.packages.length) {
this.package_id = packages[0].package_id
this.package_id = packages[0].package_id;
}
this.initialized = true
this.initialized = true;
},
error => {}
)
);
},
methods: {
import_from_list: async function (list_id) {
if (!this.package_id) {
setError(this.$__("Cannot import, no package selected"))
return
setError(this.$__("Cannot import, no package selected"));
return;
}
if (!list_id) return
const client = APIClient.erm
if (!list_id) return;
const client = APIClient.erm;
client.localTitles
.import({ list_id, package_id: this.package_id })
.then(
result => {
this.job_id = result.job_id
this.job_id = result.job_id;
},
error => {}
)
);
},
build_datatable: function () {
let lists = this.logged_in_user_lists
let table_id = this.table_id
let import_from_list = this.import_from_list
let lists = this.logged_in_user_lists;
let table_id = this.table_id;
let import_from_list = this.import_from_list;
$("#" + table_id).dataTable(
$.extend(true, {}, dataTablesDefaults, {
data: lists,
@ -100,13 +100,13 @@ export default {
" (#" +
row.shelfnumber +
")"
)
);
},
},
{
title: __("Actions"),
data: function (row, type, val, meta) {
return '<div class="actions"></div>'
return '<div class="actions"></div>';
},
className: "actions noExport",
searchable: false,
@ -114,20 +114,20 @@ export default {
},
],
drawCallback: function (settings) {
var api = new $.fn.dataTable.Api(settings)
var api = new $.fn.dataTable.Api(settings);
$.each(
$(this).find("td .actions"),
function (index, e) {
let tr = $(this).parent().parent()
let list_id = api.row(tr).data().shelfnumber
let tr = $(this).parent().parent();
let list_id = api.row(tr).data().shelfnumber;
let importButton = createVNode(
"a",
{
class: "btn btn-default btn-xs",
role: "button",
onClick: () => {
import_from_list(list_id)
import_from_list(list_id);
},
},
[
@ -137,22 +137,22 @@ export default {
}),
__("Import"),
]
)
);
let n = createVNode("span", {}, [importButton])
render(n, e)
let n = createVNode("span", {}, [importButton]);
render(n, e);
}
)
);
},
})
)
);
},
},
mounted() {
this.build_datatable()
this.build_datatable();
},
name: "EHoldingsLocalTitlesFormImport",
}
};
</script>
<style scoped>
fieldset.rows label {

View File

@ -80,20 +80,20 @@
</template>
<script>
import ButtonSubmit from "../ButtonSubmit.vue"
import { APIClient } from "../../fetch/api-client.js"
import { ref, inject } from "vue"
import ButtonSubmit from "../ButtonSubmit.vue";
import { APIClient } from "../../fetch/api-client.js";
import { ref, inject } from "vue";
export default {
setup() {
const { setMessage, setWarning } = inject("mainStore")
const { setMessage, setWarning } = inject("mainStore");
return {
setMessage,
setWarning,
}
};
},
data() {
const fileLoader = ref()
const fileLoader = ref();
return {
file: {
filename: null,
@ -103,48 +103,48 @@ export default {
package_id: null,
create_linked_biblio: false,
fileLoader,
}
};
},
beforeCreate() {
const client = APIClient.erm
const client = APIClient.erm;
client.localPackages.getAll().then(
packages => {
this.packages = packages
this.initialized = true
this.packages = packages;
this.initialized = true;
},
error => {}
)
);
},
methods: {
selectFile(e) {
let files = e.target.files
if (!files) return
let file = files[0]
const reader = new FileReader()
reader.onload = e => this.loadFile(file.name, e.target.result)
reader.readAsBinaryString(file)
let files = e.target.files;
if (!files) return;
let file = files[0];
const reader = new FileReader();
reader.onload = e => this.loadFile(file.name, e.target.result);
reader.readAsBinaryString(file);
},
loadFile(filename, content) {
this.file.filename = filename
this.file.file_content = btoa(content)
this.file.filename = filename;
this.file.file_content = btoa(content);
},
addDocument(e) {
e.preventDefault()
e.preventDefault();
const client = APIClient.erm
const client = APIClient.erm;
const importData = {
file: this.file,
package_id: this.package_id,
create_linked_biblio: this.create_linked_biblio,
}
};
client.localTitles.import_kbart(importData).then(
success => {
let message = ""
let message = "";
if (success.job_ids) {
if (success.job_ids.length > 1) {
message += `<p style='font-weight: normal; font-size: medium; margin-top: 1em;'>${this.$__(
"Your file was too large to process in one job, the file has been split into %s jobs to meet the maximum size limits."
).format(success.job_ids.length)}</p>`
).format(success.job_ids.length)}</p>`;
}
success.job_ids.forEach((job, i) => {
message += `<li>${this.$__(
@ -153,53 +153,53 @@ export default {
i + 1
)}, <a href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=${job}" target="_blank">${this.$__(
"see progress"
)}</a></li>`
})
this.setMessage(message, true)
)}</a></li>`;
});
this.setMessage(message, true);
}
if (success.warnings.invalid_columns) {
message += `<p style='font-weight: normal; font-size: medium; margin-top: 1em;'>${this.$__(
"Information:"
)}</p>`
)}</p>`;
message += `<p>${this.$__(
"Additional columns were detected in your report, please see the list below:"
)}</p>`
)}</p>`;
success.warnings.invalid_columns.forEach(column => {
message += `<li>${column}</li>`
})
message += `<li>${column}</li>`;
});
message += `<p style='margin-top: 0.1em;'>${this.$__(
"The data in these columns will not be imported."
)}</p>`
this.setMessage(message, true)
)}</p>`;
this.setMessage(message, true);
}
if (success.warnings.invalid_filetype) {
message += `<p>${this.$__(
"The file must be in .tsv or .csv format, please convert your file and try again."
)}</p>`
this.setWarning(message)
)}</p>`;
this.setWarning(message);
}
},
error => {}
)
this.clearForm()
);
this.clearForm();
},
clearForm() {
this.file = {
filename: null,
file_type: null,
file_content: null,
}
this.package_id = null
this.create_linked_biblio = false
this.$refs.fileLoader.files = null
this.$refs.fileLoader.value = null
};
this.package_id = null;
this.create_linked_biblio = false;
this.$refs.fileLoader.files = null;
this.$refs.fileLoader.value = null;
},
},
components: {
ButtonSubmit,
},
name: "EHoldingsLocalTitlesKBARTImport",
}
};
</script>
<style scoped>

View File

@ -40,26 +40,26 @@
</template>
<script>
import Toolbar from "../Toolbar.vue"
import ToolbarButton from "../ToolbarButton.vue"
import { inject, ref, reactive } from "vue"
import { storeToRefs } from "pinia"
import { APIClient } from "../../fetch/api-client.js"
import KohaTable from "../KohaTable.vue"
import Toolbar from "../Toolbar.vue";
import ToolbarButton from "../ToolbarButton.vue";
import { inject, ref, reactive } from "vue";
import { storeToRefs } from "pinia";
import { APIClient } from "../../fetch/api-client.js";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const AVStore = inject("AVStore")
const { av_title_publication_types } = storeToRefs(AVStore)
const { get_lib_from_av, map_av_dt_filter } = AVStore
const AVStore = inject("AVStore");
const { av_title_publication_types } = storeToRefs(AVStore);
const { get_lib_from_av, map_av_dt_filter } = AVStore;
const { setConfirmationDialog, setMessage } = inject("mainStore")
const { setConfirmationDialog, setMessage } = inject("mainStore");
const table = ref()
const table = ref();
const filters = reactive({
publication_title: "",
publication_type: "",
})
});
return {
av_title_publication_types,
@ -71,14 +71,14 @@ export default {
setConfirmationDialog,
setMessage,
eholdings_titles_table_settings,
}
};
},
data: function () {
this.filters = {
publication_title: this.$route.query.publication_title || "",
publication_type: this.$route.query.publication_type || "",
}
let filters = this.filters
};
let filters = this.filters;
return {
title_count: 0,
@ -107,35 +107,35 @@ export default {
},
},
cannot_search: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getTitleCount().then(() => (vm.initialized = true))
})
vm.getTitleCount().then(() => (vm.initialized = true));
});
},
methods: {
async getTitleCount() {
const client = APIClient.erm
const client = APIClient.erm;
await client.localTitles.count().then(
count => {
this.title_count = count
this.title_count = count;
},
error => {}
)
);
},
doShow: function ({ title_id }, dt, event) {
event.preventDefault()
event.preventDefault();
this.$router.push({
name: "EHoldingsLocalTitlesShow",
params: { title_id },
})
});
},
doEdit: function ({ title_id }, dt, event) {
this.$router.push({
name: "EHoldingsLocalTitlesFormAddEdit",
params: { title_id },
})
});
},
doDelete: function (title, dt, event) {
this.setConfirmationDialog(
@ -148,7 +148,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
const client = APIClient.erm;
client.localTitles.delete(title.title_id).then(
success => {
this.setMessage(
@ -156,17 +156,17 @@ export default {
title.publication_title
),
true
)
dt.draw()
);
dt.draw();
},
error => {}
)
);
}
)
);
},
getTableColumns: function () {
let get_lib_from_av = this.get_lib_from_av
let escape_str = this.escape_str
let get_lib_from_av = this.get_lib_from_av;
let escape_str = this.escape_str;
return [
{
@ -183,7 +183,7 @@ export default {
`${row.publication_title} (#${row.title_id})`
) +
"</a>"
)
);
},
},
{
@ -198,7 +198,7 @@ export default {
? "<br/>"
: "") +
escape_str(row.first_editor)
)
);
},
},
{
@ -212,7 +212,7 @@ export default {
"av_title_publication_types",
row.publication_type
)
)
);
},
},
{
@ -221,8 +221,8 @@ export default {
searchable: true,
orderable: true,
render: function (data, type, row, meta) {
let print_identifier = row.print_identifier
let online_identifier = row.online_identifier
let print_identifier = row.print_identifier;
let online_identifier = row.online_identifier;
return [
print_identifier
? escape_str(
@ -238,13 +238,13 @@ export default {
)
)
: "",
].join("<br/>")
].join("<br/>");
},
},
]
];
},
},
components: { Toolbar, ToolbarButton, KohaTable },
name: "EHoldingsLocalTitlesList",
}
};
</script>

View File

@ -263,23 +263,23 @@
</template>
<script>
import { inject } from "vue"
import EHoldingsTitlePackagesList from "./EHoldingsLocalTitlePackagesList.vue"
import { APIClient } from "../../fetch/api-client.js"
import Toolbar from "../Toolbar.vue"
import ToolbarButton from "../ToolbarButton.vue"
import { inject } from "vue";
import EHoldingsTitlePackagesList from "./EHoldingsLocalTitlePackagesList.vue";
import { APIClient } from "../../fetch/api-client.js";
import Toolbar from "../Toolbar.vue";
import ToolbarButton from "../ToolbarButton.vue";
export default {
setup() {
const AVStore = inject("AVStore")
const { get_lib_from_av } = AVStore
const { setConfirmationDialog, setMessage } = inject("mainStore")
const AVStore = inject("AVStore");
const { get_lib_from_av } = AVStore;
const { setConfirmationDialog, setMessage } = inject("mainStore");
return {
get_lib_from_av,
setConfirmationDialog,
setMessage,
}
};
},
data() {
return {
@ -313,26 +313,26 @@ export default {
resources: [],
},
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getTitle(to.params.title_id)
})
vm.getTitle(to.params.title_id);
});
},
beforeRouteUpdate(to, from) {
this.title = this.getTitle(to.params.title_id)
this.title = this.getTitle(to.params.title_id);
},
methods: {
getTitle(title_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.localTitles.get(title_id).then(
title => {
this.title = title
this.initialized = true
this.title = title;
this.initialized = true;
},
error => {}
)
);
},
delete_title: function (title_id, title_publication_title) {
this.setConfirmationDialog(
@ -345,7 +345,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
const client = APIClient.erm;
client.localTitles.delete(title_id).then(
success => {
this.setMessage(
@ -353,15 +353,15 @@ export default {
title_publication_title
),
true
)
);
this.$router.push({
name: "EHoldingsLocalTitlesList",
})
});
},
error => {}
)
);
}
)
);
},
},
components: {
@ -370,7 +370,7 @@ export default {
ToolbarButton,
},
name: "EHoldingsLocalTitlesShow",
}
};
</script>
<style scoped>
fieldset.rows label {

View File

@ -3,9 +3,9 @@
<script>
export default {
data() {
return {}
return {};
},
methods: {},
components: {},
}
};
</script>

View File

@ -139,28 +139,28 @@
</template>
<script>
import { inject } from "vue"
import flatPickr from "vue-flatpickr-component"
import UserRoles from "./UserRoles.vue"
import Documents from "./Documents.vue"
import AdditionalFieldsEntry from "../AdditionalFieldsEntry.vue"
import FormSelectVendors from "../FormSelectVendors.vue"
import { setMessage, setWarning } from "../../messages"
import { APIClient } from "../../fetch/api-client.js"
import { storeToRefs } from "pinia"
import { inject } from "vue";
import flatPickr from "vue-flatpickr-component";
import UserRoles from "./UserRoles.vue";
import Documents from "./Documents.vue";
import AdditionalFieldsEntry from "../AdditionalFieldsEntry.vue";
import FormSelectVendors from "../FormSelectVendors.vue";
import { setMessage, setWarning } from "../../messages";
import { APIClient } from "../../fetch/api-client.js";
import { storeToRefs } from "pinia";
export default {
setup() {
const AVStore = inject("AVStore")
const AVStore = inject("AVStore");
const { av_license_types, av_license_statuses, av_user_roles } =
storeToRefs(AVStore)
storeToRefs(AVStore);
return {
av_license_types,
av_license_statuses,
av_user_roles,
max_allowed_packet,
}
};
},
data() {
return {
@ -179,31 +179,31 @@ export default {
extended_attributes: [],
},
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (to.params.license_id) {
vm.license = vm.getLicense(to.params.license_id)
vm.license = vm.getLicense(to.params.license_id);
} else {
vm.initialized = true
vm.initialized = true;
}
})
});
},
methods: {
async getLicense(license_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.licenses.get(license_id).then(license => {
this.license = license
this.initialized = true
})
this.license = license;
this.initialized = true;
});
},
checkForm(license) {
let errors = []
let errors = [];
let documents_with_uploaded_files = license.documents.filter(
doc => typeof doc.file_content !== "undefined"
)
);
if (
documents_with_uploaded_files.filter(
doc => atob(doc.file_content).length >= max_allowed_packet
@ -213,7 +213,7 @@ export default {
this.$__("File size exceeds maximum allowed: %s MB").format(
(max_allowed_packet / (1024 * 1024)).toFixed(2)
)
)
);
}
license.user_roles.forEach((user, i) => {
if (user.patron_str === "") {
@ -221,59 +221,59 @@ export default {
this.$__("License user %s is missing a user").format(
i + 1
)
)
);
}
})
setWarning(errors.join("<br>"))
return !errors.length
});
setWarning(errors.join("<br>"));
return !errors.length;
},
onSubmit(e) {
e.preventDefault()
e.preventDefault();
let license = JSON.parse(JSON.stringify(this.license)) // copy
let license_id = license.license_id
let license = JSON.parse(JSON.stringify(this.license)); // copy
let license_id = license.license_id;
if (!this.checkForm(license)) {
return false
return false;
}
delete license.license_id
delete license.vendor
delete license._strings
delete license.license_id;
delete license.vendor;
delete license._strings;
if (license.vendor_id == "") {
license.vendor_id = null
license.vendor_id = null;
}
license.user_roles = license.user_roles.map(
({ patron, patron_str, ...keepAttrs }) => keepAttrs
)
);
license.documents = license.documents.map(
({ file_type, uploaded_on, ...keepAttrs }) => keepAttrs
)
);
const client = APIClient.erm
const client = APIClient.erm;
if (license_id) {
client.licenses.update(license, license_id).then(
success => {
setMessage(this.$__("License updated"))
this.$router.push({ name: "LicensesList" })
setMessage(this.$__("License updated"));
this.$router.push({ name: "LicensesList" });
},
error => {}
)
);
} else {
client.licenses.create(license).then(
success => {
setMessage(this.$__("License created"))
this.$router.push({ name: "LicensesList" })
setMessage(this.$__("License created"));
this.$router.push({ name: "LicensesList" });
},
error => {}
)
);
}
},
additionalFieldsChanged(additionalFieldValues) {
this.license.extended_attributes = additionalFieldValues
this.license.extended_attributes = additionalFieldValues;
},
},
components: {
@ -284,5 +284,5 @@ export default {
AdditionalFieldsEntry,
},
name: "LicensesFormAdd",
}
};
</script>

View File

@ -26,24 +26,24 @@
</template>
<script>
import Toolbar from "../Toolbar.vue"
import ToolbarButton from "../ToolbarButton.vue"
import { inject, ref } from "vue"
import { storeToRefs } from "pinia"
import { APIClient } from "../../fetch/api-client.js"
import KohaTable from "../KohaTable.vue"
import Toolbar from "../Toolbar.vue";
import ToolbarButton from "../ToolbarButton.vue";
import { inject, ref } from "vue";
import { storeToRefs } from "pinia";
import { APIClient } from "../../fetch/api-client.js";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const vendorStore = inject("vendorStore")
const { vendors } = storeToRefs(vendorStore)
const vendorStore = inject("vendorStore");
const { vendors } = storeToRefs(vendorStore);
const AVStore = inject("AVStore")
const { get_lib_from_av, map_av_dt_filter } = AVStore
const AVStore = inject("AVStore");
const { get_lib_from_av, map_av_dt_filter } = AVStore;
const { setConfirmationDialog, setMessage } = inject("mainStore")
const { setConfirmationDialog, setMessage } = inject("mainStore");
const table = ref()
const table = ref();
return {
vendors,
@ -53,7 +53,7 @@ export default {
setConfirmationDialog,
setMessage,
license_table_settings,
}
};
},
data: function () {
return {
@ -77,9 +77,9 @@ export default {
filters_options: {
1: () =>
this.vendors.map(e => {
e["_id"] = e["id"]
e["_str"] = e["name"]
return e
e["_id"] = e["id"];
e["_str"] = e["name"];
return e;
}),
3: () => this.map_av_dt_filter("av_license_types"),
4: () => this.map_av_dt_filter("av_license_statuses"),
@ -89,7 +89,7 @@ export default {
"-1": ["edit", "delete"],
},
},
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
@ -101,36 +101,36 @@ export default {
.getSearchableAVOptions()
.then(() => (vm.initialized = true))
)
)
})
);
});
},
methods: {
async getLicenseCount() {
const client = APIClient.erm
const client = APIClient.erm;
await client.licenses.count().then(
count => {
this.license_count = count
this.license_count = count;
},
error => {}
)
);
},
async getSearchableAdditionalFields() {
const client = APIClient.additional_fields
const client = APIClient.additional_fields;
await client.additional_fields.getAll("license").then(
searchable_additional_fields => {
this.searchable_additional_fields =
searchable_additional_fields.filter(
field => field.searchable
)
);
},
error => {}
)
);
},
async getSearchableAVOptions() {
const client_av = APIClient.authorised_values
const client_av = APIClient.authorised_values;
let av_cat_array = this.searchable_additional_fields
.filter(field => field.authorised_value_category_name)
.map(field => field.authorised_value_category_name)
.map(field => field.authorised_value_category_name);
await client_av.values
.getCategoriesWithValues([
@ -140,24 +140,24 @@ export default {
av_cat_array.forEach(av_cat => {
let av_match = av_categories.find(
element => element.category_name == av_cat
)
);
this.searchable_av_options[av_cat] =
av_match.authorised_values.map(av => ({
value: av.value,
label: av.description,
}))
})
})
}));
});
});
},
doShow: function ({ license_id }, dt, event) {
event.preventDefault()
this.$router.push({ name: "LicensesShow", params: { license_id } })
event.preventDefault();
this.$router.push({ name: "LicensesShow", params: { license_id } });
},
doEdit: function ({ license_id }, dt, event) {
this.$router.push({
name: "LicensesFormAddEdit",
params: { license_id },
})
});
},
doDelete: function (license, dt, event) {
this.setConfirmationDialog(
@ -170,7 +170,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
const client = APIClient.erm;
client.licenses.delete(license.license_id).then(
success => {
this.setMessage(
@ -178,16 +178,16 @@ export default {
license.name
),
true
)
dt.draw()
);
dt.draw();
},
error => {}
)
);
}
)
);
},
getTableColumns: function () {
let get_lib_from_av = this.get_lib_from_av
let get_lib_from_av = this.get_lib_from_av;
return [
{
@ -202,7 +202,7 @@ export default {
'" class="show">' +
escape_str(`${row.name} (#${row.license_id})`) +
"</a>"
)
);
},
},
{
@ -217,7 +217,7 @@ export default {
'">' +
escape_str(row.vendor.name) +
"</a>"
: ""
: "";
},
},
@ -235,7 +235,7 @@ export default {
render: function (data, type, row, meta) {
return escape_str(
get_lib_from_av("av_license_types", row.type)
)
);
},
},
{
@ -246,7 +246,7 @@ export default {
render: function (data, type, row, meta) {
return escape_str(
get_lib_from_av("av_license_statuses", row.status)
)
);
},
},
{
@ -255,7 +255,7 @@ export default {
searchable: true,
orderable: true,
render: function (data, type, row, meta) {
return $date(row.started_on)
return $date(row.started_on);
},
},
{
@ -264,10 +264,10 @@ export default {
searchable: true,
orderable: true,
render: function (data, type, row, meta) {
return $date(row.ended_on)
return $date(row.ended_on);
},
},
]
];
},
},
props: {
@ -276,5 +276,5 @@ export default {
},
components: { Toolbar, ToolbarButton, KohaTable },
name: "LicensesList",
}
};
</script>

View File

@ -155,21 +155,21 @@
</template>
<script>
import { inject } from "vue"
import { APIClient } from "../../fetch/api-client.js"
import Toolbar from "../Toolbar.vue"
import ToolbarButton from "../ToolbarButton.vue"
import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue"
import { inject } from "vue";
import { APIClient } from "../../fetch/api-client.js";
import Toolbar from "../Toolbar.vue";
import ToolbarButton from "../ToolbarButton.vue";
import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue";
export default {
setup() {
const format_date = $date
const patron_to_html = $patron_to_html
const format_date = $date;
const patron_to_html = $patron_to_html;
const { setConfirmationDialog, setMessage } = inject("mainStore")
const { setConfirmationDialog, setMessage } = inject("mainStore");
const AVStore = inject("AVStore")
const { get_lib_from_av } = AVStore
const AVStore = inject("AVStore");
const { get_lib_from_av } = AVStore;
return {
format_date,
@ -177,7 +177,7 @@ export default {
get_lib_from_av,
setConfirmationDialog,
setMessage,
}
};
},
data() {
return {
@ -196,23 +196,23 @@ export default {
ended_on: undefined,
},
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.license = vm.getLicense(to.params.license_id)
})
vm.license = vm.getLicense(to.params.license_id);
});
},
methods: {
async getLicense(license_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.licenses.get(license_id).then(
license => {
this.license = license
this.initialized = true
this.license = license;
this.initialized = true;
},
error => {}
)
);
},
delete_license: function (license_id, license_name) {
this.setConfirmationDialog(
@ -225,7 +225,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
const client = APIClient.erm;
client.licenses.delete(license_id).then(
success => {
this.setMessage(
@ -233,18 +233,18 @@ export default {
license_name
),
true
)
this.$router.push({ name: "LicensesList" })
);
this.$router.push({ name: "LicensesList" });
},
error => {}
)
);
}
)
);
},
},
components: { Toolbar, ToolbarButton, AdditionalFieldsDisplay },
name: "LicensesShow",
}
};
</script>
<style scoped>
#license_documents ul {

View File

@ -28,28 +28,28 @@
</template>
<script>
import { inject } from "vue"
import Breadcrumbs from "../Breadcrumbs.vue"
import Help from "../Help.vue"
import LeftMenu from "../LeftMenu.vue"
import Dialog from "../Dialog.vue"
import { APIClient } from "../../fetch/api-client.js"
import "vue-select/dist/vue-select.css"
import { storeToRefs } from "pinia"
import { inject } from "vue";
import Breadcrumbs from "../Breadcrumbs.vue";
import Help from "../Help.vue";
import LeftMenu from "../LeftMenu.vue";
import Dialog from "../Dialog.vue";
import { APIClient } from "../../fetch/api-client.js";
import "vue-select/dist/vue-select.css";
import { storeToRefs } from "pinia";
export default {
setup() {
const vendorStore = inject("vendorStore")
const vendorStore = inject("vendorStore");
const AVStore = inject("AVStore")
const AVStore = inject("AVStore");
const mainStore = inject("mainStore")
const mainStore = inject("mainStore");
const { loading, loaded, setError } = mainStore
const { loading, loaded, setError } = mainStore;
const ERMStore = inject("ERMStore")
const ERMStore = inject("ERMStore");
const { config } = storeToRefs(ERMStore)
const { config } = storeToRefs(ERMStore);
return {
vendorStore,
@ -59,29 +59,29 @@ export default {
setError,
loading,
loaded,
}
};
},
data() {
return {
component: "agreement",
initialized: false,
}
};
},
beforeCreate() {
this.loading()
this.loading();
const fetch_config = () => {
let promises = []
let promises = [];
const acq_client = APIClient.acquisition
const acq_client = APIClient.acquisition;
acq_client.vendors.getAll().then(
vendors => {
this.vendorStore.vendors = vendors
this.vendorStore.vendors = vendors;
},
error => {}
)
);
const av_client = APIClient.authorised_values
const av_client = APIClient.authorised_values;
const authorised_values = {
av_agreement_statuses: "ERM_AGREEMENT_STATUS",
av_agreement_closure_reasons: "ERM_AGREEMENT_CLOSURE_REASON",
@ -100,13 +100,13 @@ export default {
av_database_reports_metrics: "ERM_DATABASE_REPORTS_METRICS",
av_title_reports_metrics: "ERM_TITLE_REPORTS_METRICS",
av_item_reports_metrics: "ERM_ITEM_REPORTS_METRICS",
}
};
let av_cat_array = Object.keys(authorised_values).map(
function (av_cat) {
return '"' + authorised_values[av_cat] + '"'
return '"' + authorised_values[av_cat] + '"';
}
)
);
promises.push(
av_client.values
@ -116,49 +116,49 @@ export default {
([av_var, av_cat]) => {
const av_match = av_categories.find(
element => element.category_name == av_cat
)
);
this.AVStore[av_var] =
av_match.authorised_values
av_match.authorised_values;
}
)
);
})
)
);
return Promise.all(promises)
}
return Promise.all(promises);
};
const client = APIClient.erm
const client = APIClient.erm;
client.config
.get()
.then(config => {
this.config = config
this.config = config;
if (this.config.settings.ERMModule != 1) {
return this.setError(
this.$__(
"The e-resource management module is disabled, turn on <a href='/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=ERMModule'>ERMModule</a> to use it"
),
false
)
);
}
return fetch_config()
return fetch_config();
})
.then(() => {
this.loaded()
this.initialized = true
})
this.loaded();
this.initialized = true;
});
},
methods: {
async filterProviders(navigationTree) {
const eHoldings = navigationTree.find(
element => element.path === "/cgi-bin/koha/erm/eholdings"
)
const providers = this.config.settings.ERMProviders
);
const providers = this.config.settings.ERMProviders;
eHoldings.children = eHoldings.children.filter(element =>
providers
.map(provider => `${eHoldings.path}/${provider}`)
.includes(element.path)
)
return navigationTree
);
return navigationTree;
},
},
components: {
@ -167,7 +167,7 @@ export default {
Help,
LeftMenu,
},
}
};
</script>
<style>

View File

@ -97,7 +97,7 @@
export default {
props: ["usage_data_provider"],
name: "UsageStatisticsDataProviderDetails",
}
};
</script>
<style scoped>

View File

@ -16,21 +16,21 @@
</template>
<script>
import { APIClient } from "../../fetch/api-client.js"
import { inject, ref } from "vue"
import KohaTable from "../KohaTable.vue"
import { APIClient } from "../../fetch/api-client.js";
import { inject, ref } from "vue";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const { setConfirmationDialog, setMessage } = inject("mainStore")
const { setConfirmationDialog, setMessage } = inject("mainStore");
const table = ref()
const table = ref();
return {
table,
setConfirmationDialog,
setMessage,
}
};
},
data: function () {
return {
@ -60,11 +60,11 @@ export default {
],
},
},
}
};
},
methods: {
async getCounterFiles() {
const client = APIClient.erm
const client = APIClient.erm;
await client.counter_files
.count({
usage_data_provider_id:
@ -72,21 +72,21 @@ export default {
})
.then(
count => {
this.counter_files_count = count
this.initialized = true
this.counter_files_count = count;
this.initialized = true;
},
error => {}
)
);
},
table_url() {
let url = `/api/v1/erm/counter_logs?usage_data_provider_id=${this.$route.params.usage_data_provider_id}`
return url
let url = `/api/v1/erm/counter_logs?usage_data_provider_id=${this.$route.params.usage_data_provider_id}`;
return url;
},
download_counter_file(counter_log, dt, event) {
window.location.href =
"/api/v1/erm/counter_files/" +
counter_log.counter_files_id +
"/file/content"
"/file/content";
},
delete_counter_file(counter_log, dt, event) {
this.setConfirmationDialog(
@ -99,7 +99,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
const client = APIClient.erm;
client.counter_files
.delete(counter_log.counter_files_id)
.then(
@ -109,13 +109,13 @@ export default {
counter_log.filename
),
true
)
dt.draw()
);
dt.draw();
},
error => {}
)
);
}
)
);
},
getTableColumns() {
return [
@ -129,9 +129,9 @@ export default {
data: "importdate",
title: __("Import date"),
render: function (data, type, row, meta) {
const date = row.importdate.substr(0, 10)
const time = row.importdate.substr(11, 8)
return `${date} ${time}`
const date = row.importdate.substr(0, 10);
const time = row.importdate.substr(11, 8);
return `${date} ${time}`;
},
searchable: true,
orderable: true,
@ -139,31 +139,31 @@ export default {
{
title: __("Imported by"),
render: function (data, type, row, meta) {
const { patron } = row
const { patron } = row;
const importer = patron
? '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=' +
patron.patron_id +
'">' +
$patron_to_html(patron) +
"</a>"
: this.$__("Cronjob")
return importer
: this.$__("Cronjob");
return importer;
},
searchable: true,
orderable: true,
},
]
];
},
},
mounted() {
if (!this.building_table) {
this.building_table = true
this.getCounterFiles()
this.building_table = true;
this.getCounterFiles();
}
},
components: { KohaTable },
name: "UsageStatisticsTitlesList",
}
};
</script>
<style scoped>

View File

@ -35,20 +35,20 @@
</template>
<script>
import { inject } from "vue"
import ButtonSubmit from "../ButtonSubmit.vue"
import { APIClient } from "../../fetch/api-client.js"
import { inject } from "vue";
import ButtonSubmit from "../ButtonSubmit.vue";
import { APIClient } from "../../fetch/api-client.js";
export default {
setup() {
const AVStore = inject("AVStore") // Left in for future permissions fixes
const { get_lib_from_av, map_av_dt_filter } = AVStore
const AVStore = inject("AVStore"); // Left in for future permissions fixes
const { get_lib_from_av, map_av_dt_filter } = AVStore;
const { setMessage } = inject("mainStore")
const { setMessage } = inject("mainStore");
return {
setMessage,
}
};
},
data() {
return {
@ -60,25 +60,25 @@ export default {
date: null,
date_uploaded: null,
},
}
};
},
methods: {
selectFile(e) {
let files = e.target.files
if (!files) return
let file = files[0]
const reader = new FileReader()
reader.onload = e => this.loadFile(file.name, e.target.result)
reader.readAsBinaryString(file)
let files = e.target.files;
if (!files) return;
let file = files[0];
const reader = new FileReader();
reader.onload = e => this.loadFile(file.name, e.target.result);
reader.readAsBinaryString(file);
},
loadFile(filename, content) {
this.file.filename = filename
this.file.file_content = btoa(content)
this.getDataProvider(this.$route.params.usage_data_provider_id)
this.file.filename = filename;
this.file.file_content = btoa(content);
this.getDataProvider(this.$route.params.usage_data_provider_id);
},
addDocument(e) {
e.preventDefault()
const client = APIClient.erm
e.preventDefault();
const client = APIClient.erm;
client.usage_data_providers
.process_COUNTER_file(this.file.usage_data_provider_id, {
usage_data_provider_id: this.file.usage_data_provider_id,
@ -87,7 +87,7 @@ export default {
})
.then(
success => {
let message = ""
let message = "";
success.jobs.forEach((job, i) => {
message +=
"<li>" +
@ -98,15 +98,15 @@ export default {
job.job_id +
'" target="_blank">' +
this.$__("Check job progress") +
".</a></li>"
})
this.setMessage(message, true)
".</a></li>";
});
this.setMessage(message, true);
},
error => {}
)
);
},
clearForm(e) {
e.preventDefault()
e.preventDefault();
this.file = {
filename: null,
@ -115,27 +115,27 @@ export default {
file_content: null,
date: null,
date_uploaded: null,
}
};
},
async getDataProvider(usage_data_provider_id) {
const client = APIClient.erm
const client = APIClient.erm;
await client.usage_data_providers.get(usage_data_provider_id).then(
usage_data_provider => {
this.file.usage_data_provider_id =
usage_data_provider.erm_usage_data_provider_id
usage_data_provider.erm_usage_data_provider_id;
},
error => {}
)
);
},
},
mounted() {
this.getDataProvider(this.$route.params.usage_data_provider_id)
this.getDataProvider(this.$route.params.usage_data_provider_id);
},
components: {
ButtonSubmit,
},
name: "UsageStatisticsDataProvidersFileImport",
}
};
</script>
<style scoped>

View File

@ -384,20 +384,20 @@
</template>
<script>
import ButtonSubmit from "../ButtonSubmit.vue"
import { setMessage, setWarning } from "../../messages"
import { APIClient } from "../../fetch/api-client.js"
import { inject } from "vue"
import { storeToRefs } from "pinia"
import ButtonSubmit from "../ButtonSubmit.vue";
import { setMessage, setWarning } from "../../messages";
import { APIClient } from "../../fetch/api-client.js";
import { inject } from "vue";
import { storeToRefs } from "pinia";
export default {
setup() {
const AVStore = inject("AVStore")
const { av_report_types } = storeToRefs(AVStore)
const AVStore = inject("AVStore");
const { av_report_types } = storeToRefs(AVStore);
return {
av_report_types,
}
};
},
data() {
return {
@ -431,190 +431,192 @@ export default {
required_fields: [],
sushi_service: null,
searching: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (to.params.usage_data_provider_id) {
vm.getDataProvider(to.params.usage_data_provider_id)
vm.getDataProvider(to.params.usage_data_provider_id);
} else {
vm.initialized = true
vm.initialized = true;
}
if (from.params.usage_data_provider_id) {
vm.previous_route = "data_provider_show"
vm.previous_route = "data_provider_show";
} else {
vm.previous_route = "data_provider_list"
vm.previous_route = "data_provider_list";
}
})
});
},
methods: {
async getDataProvider(erm_usage_data_provider_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.usage_data_providers.get(erm_usage_data_provider_id).then(
usage_data_provider => {
this.usage_data_provider = usage_data_provider
this.usage_data_provider = usage_data_provider;
this.usage_data_provider.report_types =
this.formatReportTypes(usage_data_provider.report_types)
this.getCounterRegistry(usage_data_provider.name, "edit")
this.formatReportTypes(
usage_data_provider.report_types
);
this.getCounterRegistry(usage_data_provider.name, "edit");
},
error => {}
)
);
},
async getCounterRegistry(query, caller) {
const client = APIClient.erm
const client = APIClient.erm;
client.counter_registry.getAll({ name: query }).then(
registry_data => {
this.registry_data = registry_data
this.registry_data = registry_data;
if (caller === "edit" && registry_data.length > 0) {
this.selected_provider = registry_data.find(
platform =>
platform.name === this.usage_data_provider.name
)
);
this.valid_report_types =
this.valid_report_types.filter(report =>
this.selected_provider.reports.some(
r => r.report_id === report.value
)
)
);
}
if (caller === "edit" && registry_data.length === 0) {
this.manual_form = true
this.manual_form = true;
}
this.searching = false
this.initialized = true
this.searching = false;
this.initialized = true;
},
error => {}
)
);
},
async getSushiService(url) {
const client = APIClient.erm
const client = APIClient.erm;
client.sushi_service.getAll({ url }).then(
sushi_service => {
const { url, api_key_required, requestor_id_required } =
sushi_service
this.usage_data_provider.service_url = url
this.required_fields = ["URL", "Release", "Customer"]
api_key_required && this.required_fields.push("API")
sushi_service;
this.usage_data_provider.service_url = url;
this.required_fields = ["URL", "Release", "Customer"];
api_key_required && this.required_fields.push("API");
requestor_id_required &&
this.required_fields.push("Requestor")
this.sushi_service = sushi_service || {}
this.required_fields.push("Requestor");
this.sushi_service = sushi_service || {};
},
error => {}
)
);
},
getPlatformData(e) {
if (e.target.value.length > 1) {
this.searching = true
this.getCounterRegistry(e.target.value, "search")
this.searching = true;
this.getCounterRegistry(e.target.value, "search");
}
},
async setPlatformData(e) {
const { sushi_services, reports, name } = e
const { sushi_services, reports, name } = e;
this.valid_report_types = this.valid_report_types.filter(report =>
reports.some(r => r.report_id === report.value)
)
);
if (this.valid_report_types.length === 0) {
setWarning(
this.$__(
"This provider does not currently support any COUNTER 5 reports via SUSHI."
)
)
);
}
this.selected_provider = e
this.usage_data_provider.name = name
await this.getSushiService(sushi_services[0].url)
this.selected_provider = e;
this.usage_data_provider.name = name;
await this.getSushiService(sushi_services[0].url);
this.usage_data_provider.report_release =
sushi_services[0].counter_release
sushi_services[0].counter_release;
},
createManualProvider() {
this.manual_form = true
this.selected_provider = null
this.sushi_service = null
this.required_fields = []
this.manual_form = true;
this.selected_provider = null;
this.sushi_service = null;
this.required_fields = [];
},
createFromRegistry() {
this.manual_form = false
this.selected_provider = null
this.sushi_service = null
this.required_fields = []
this.usage_data_provider.report_types = []
this.manual_form = false;
this.selected_provider = null;
this.sushi_service = null;
this.required_fields = [];
this.usage_data_provider.report_types = [];
},
selectAll() {
this.usage_data_provider.report_types = this.valid_report_types.map(
report => {
return report.value
return report.value;
}
)
);
},
unselectAll() {
this.usage_data_provider.report_types = []
this.usage_data_provider.report_types = [];
},
formatReportTypes(reportTypes) {
const dataType =
typeof reportTypes === "string" ? "string" : "array"
typeof reportTypes === "string" ? "string" : "array";
if (dataType === "array") {
let report_types_string = ""
let report_types_string = "";
reportTypes.forEach(item => {
report_types_string += item
report_types_string += ";"
})
return report_types_string
report_types_string += item;
report_types_string += ";";
});
return report_types_string;
}
if (dataType === "string") {
const single_report_types = reportTypes.split(";")
single_report_types.pop() // remove trailing "" from array
return single_report_types
const single_report_types = reportTypes.split(";");
single_report_types.pop(); // remove trailing "" from array
return single_report_types;
}
},
onSubmit(e) {
e.preventDefault()
e.preventDefault();
let usage_data_provider = JSON.parse(
JSON.stringify(this.usage_data_provider)
)
);
let erm_usage_data_provider_id =
usage_data_provider.erm_usage_data_provider_id
usage_data_provider.erm_usage_data_provider_id;
usage_data_provider.report_types = this.formatReportTypes(
usage_data_provider.report_types
)
);
delete usage_data_provider.erm_usage_data_provider_id
delete usage_data_provider.erm_usage_data_provider_id;
const client = APIClient.erm
const client = APIClient.erm;
if (erm_usage_data_provider_id) {
client.usage_data_providers
.update(usage_data_provider, erm_usage_data_provider_id)
.then(
success => {
setMessage(this.$__("Data provider updated"))
setMessage(this.$__("Data provider updated"));
this.$router.push({
name: "UsageStatisticsDataProvidersShow",
params: {
usage_data_provider_id:
erm_usage_data_provider_id,
},
})
});
},
error => {}
)
);
} else {
client.usage_data_providers.create(usage_data_provider).then(
success => {
erm_usage_data_provider_id =
success.erm_usage_data_provider_id
setMessage(this.$__("Data provider created"))
success.erm_usage_data_provider_id;
setMessage(this.$__("Data provider created"));
this.$router.push({
name: "UsageStatisticsDataProvidersShow",
params: {
usage_data_provider_id:
erm_usage_data_provider_id,
},
})
});
},
error => {}
)
);
}
},
},
@ -622,7 +624,7 @@ export default {
ButtonSubmit,
},
name: "UsageStatisticsDataProvidersFormAdd",
}
};
</script>
<style scoped>

View File

@ -35,20 +35,20 @@
</template>
<script>
import Toolbar from "./UsageStatisticsDataProvidersToolbar.vue"
import { inject, ref } from "vue"
import { APIClient } from "../../fetch/api-client.js"
import KohaTable from "../KohaTable.vue"
import Toolbar from "./UsageStatisticsDataProvidersToolbar.vue";
import { inject, ref } from "vue";
import { APIClient } from "../../fetch/api-client.js";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const AVStore = inject("AVStore") // Left in for future permissions fixes
const { get_lib_from_av, map_av_dt_filter } = AVStore
const AVStore = inject("AVStore"); // Left in for future permissions fixes
const { get_lib_from_av, map_av_dt_filter } = AVStore;
const { setConfirmationDialog, setMessage, setWarning } =
inject("mainStore")
inject("mainStore");
const table = ref()
const table = ref();
return {
get_lib_from_av,
@ -57,7 +57,7 @@ export default {
setMessage,
setWarning,
table,
}
};
},
data: function () {
return {
@ -90,25 +90,25 @@ export default {
],
},
},
}
};
},
methods: {
async getUsageDataProviderCount() {
const client = APIClient.erm
const client = APIClient.erm;
await client.usage_data_providers.count().then(
count => {
this.usage_data_provider_count = count
this.initialized = true
this.usage_data_provider_count = count;
this.initialized = true;
},
error => {}
)
);
},
table_url() {
let url = "/api/v1/erm/usage_data_providers"
return url
let url = "/api/v1/erm/usage_data_providers";
return url;
},
show_usage_data_provider(usage_data_provider, dt, event) {
event.preventDefault()
event.preventDefault();
this.$router.push({
name: "UsageStatisticsDataProvidersShow",
@ -116,7 +116,7 @@ export default {
usage_data_provider_id:
usage_data_provider.erm_usage_data_provider_id,
},
})
});
},
edit_usage_data_provider(usage_data_provider, dt, event) {
this.$router.push({
@ -125,7 +125,7 @@ export default {
usage_data_provider_id:
usage_data_provider.erm_usage_data_provider_id,
},
})
});
},
delete_usage_data_provider(usage_data_provider, dt, event) {
this.setConfirmationDialog(
@ -138,7 +138,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
const client = APIClient.erm;
client.usage_data_providers
.delete(usage_data_provider.erm_usage_data_provider_id)
.then(
@ -148,16 +148,17 @@ export default {
usage_data_provider.name
),
true
)
dt.draw()
);
dt.draw();
},
error => {}
)
);
}
)
);
},
run_harvester_now(usage_data_provider, dt, event) {
const { erm_usage_data_provider_id: id, name } = usage_data_provider
const { erm_usage_data_provider_id: id, name } =
usage_data_provider;
if (!usage_data_provider.active) {
this.setConfirmationDialog(
@ -170,19 +171,19 @@ export default {
cancel_label: this.$__("No, do not update status"),
},
() => {
usage_data_provider.active = 1
delete usage_data_provider.erm_usage_data_provider_id
usage_data_provider.active = 1;
delete usage_data_provider.erm_usage_data_provider_id;
// const counter_files = usage_data_provider.counter_files
// delete usage_data_provider.counter_files
delete usage_data_provider.earliest_platform
delete usage_data_provider.latest_platform
delete usage_data_provider.earliest_title
delete usage_data_provider.latest_title
delete usage_data_provider.earliest_database
delete usage_data_provider.latest_database
delete usage_data_provider.earliest_item
delete usage_data_provider.latest_item
const client = APIClient.erm
delete usage_data_provider.earliest_platform;
delete usage_data_provider.latest_platform;
delete usage_data_provider.earliest_title;
delete usage_data_provider.latest_title;
delete usage_data_provider.earliest_database;
delete usage_data_provider.latest_database;
delete usage_data_provider.earliest_item;
delete usage_data_provider.latest_item;
const client = APIClient.erm;
client.usage_data_providers
.update(usage_data_provider, id)
.then(
@ -192,17 +193,17 @@ export default {
"Updated status for usage data provider %s"
).format(name),
true
)
);
// usage_data_provider.counter_files =
// counter_files
dt.draw()
dt.draw();
},
error => {}
)
);
}
)
);
} else {
let date = new Date()
let date = new Date();
this.setConfirmationDialog(
{
title: this.$__(
@ -229,21 +230,21 @@ export default {
],
},
callback_result => {
const client = APIClient.erm
const client = APIClient.erm;
client.usage_data_providers
.process_SUSHI_response(id, {
begin_date: callback_result.inputs.find(
input => {
return input.id == "begin_date"
return input.id == "begin_date";
}
).value,
end_date: callback_result.inputs.find(input => {
return input.id == "end_date"
return input.id == "end_date";
}).value,
})
.then(
success => {
let message = ""
let message = "";
success.jobs.forEach((job, i) => {
message +=
"<li>" +
@ -254,21 +255,22 @@ export default {
job.job_id +
'" target="_blank">' +
this.$__("Check job progress") +
".</a></li>"
})
this.setMessage(message, true)
".</a></li>";
});
this.setMessage(message, true);
},
error => {}
)
);
}
)
);
}
},
test_harvester_connection(usage_data_provider, dt, event) {
const { erm_usage_data_provider_id: id, name } = usage_data_provider
const { erm_usage_data_provider_id: id, name } =
usage_data_provider;
if (usage_data_provider.active) {
const client = APIClient.erm
const client = APIClient.erm;
client.usage_data_providers.test(id).then(
success => {
if (success) {
@ -277,25 +279,25 @@ export default {
"Harvester connection was successful for usage data provider %s"
).format(name),
true
)
);
} else {
this.setMessage(
this.$__(
"No connection for usage data provider %s, please check your credentials and try again."
).format(name),
true
)
);
}
},
error => {}
)
);
} else {
this.setWarning(
this.$__(
"This data provider is inactive - connection testing is not possible"
),
true
)
);
}
},
getTableColumns() {
@ -314,7 +316,7 @@ export default {
`${row.name} (#${row.erm_usage_data_provider_id})`
) +
"</a>"
)
);
},
},
{
@ -326,8 +328,8 @@ export default {
{
title: __("Status"),
render: function (data, type, row, meta) {
const status = row.active ? "Active" : "Inactive"
return status
const status = row.active ? "Active" : "Inactive";
return status;
},
searchable: true,
orderable: true,
@ -338,18 +340,18 @@ export default {
searchable: true,
orderable: true,
},
]
];
},
},
mounted() {
if (!this.building_table) {
this.building_table = true
this.getUsageDataProviderCount()
this.building_table = true;
this.getUsageDataProviderCount();
}
},
components: { Toolbar, KohaTable },
name: "DataProvidersList",
}
};
</script>
<style scoped>

View File

@ -117,27 +117,27 @@
</template>
<script>
import { inject } from "vue"
import { APIClient } from "../../fetch/api-client.js"
import Toolbar from "../Toolbar.vue"
import ToolbarButton from "../ToolbarButton.vue"
import UsageStatisticsDataProvidersFileImport from "./UsageStatisticsDataProvidersFileImport.vue"
import UsageStatisticsDataProvidersCounterLogs from "./UsageStatisticsDataProvidersCounterLogs.vue"
import UsageStatisticsDataProviderDetails from "./UsageStatisticsDataProviderDetails.vue"
import UsageStatisticsProviderDataList from "./UsageStatisticsProviderDataList.vue"
import { inject } from "vue";
import { APIClient } from "../../fetch/api-client.js";
import Toolbar from "../Toolbar.vue";
import ToolbarButton from "../ToolbarButton.vue";
import UsageStatisticsDataProvidersFileImport from "./UsageStatisticsDataProvidersFileImport.vue";
import UsageStatisticsDataProvidersCounterLogs from "./UsageStatisticsDataProvidersCounterLogs.vue";
import UsageStatisticsDataProviderDetails from "./UsageStatisticsDataProviderDetails.vue";
import UsageStatisticsProviderDataList from "./UsageStatisticsProviderDataList.vue";
export default {
setup() {
const AVStore = inject("AVStore")
const { get_lib_from_av } = AVStore
const AVStore = inject("AVStore");
const { get_lib_from_av } = AVStore;
const { setConfirmationDialog, setMessage } = inject("mainStore")
const { setConfirmationDialog, setMessage } = inject("mainStore");
return {
get_lib_from_av,
setConfirmationDialog,
setMessage,
}
};
},
data() {
return {
@ -178,26 +178,26 @@ export default {
tab_name: this.$__("Databases"),
},
],
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getUsageDataProvider(to.params.usage_data_provider_id)
})
vm.getUsageDataProvider(to.params.usage_data_provider_id);
});
},
methods: {
async getUsageDataProvider(usage_data_provider_id) {
const client = APIClient.erm
const client = APIClient.erm;
client.usage_data_providers.get(usage_data_provider_id).then(
usage_data_provider => {
this.usage_data_provider = usage_data_provider
this.initialized = true
this.usage_data_provider = usage_data_provider;
this.initialized = true;
},
error => {}
)
);
},
change_tab_content(e) {
this.tab_content = e.target.getAttribute("data-content")
this.tab_content = e.target.getAttribute("data-content");
},
delete_usage_data_provider: function (
usage_data_provider_id,
@ -213,7 +213,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.erm
const client = APIClient.erm;
client.usage_data_providers
.delete(usage_data_provider_id)
.then(
@ -223,15 +223,15 @@ export default {
"Usage data provider %s deleted"
).format(usage_data_provider_name),
true
)
);
this.$router.push({
name: "UsageStatisticsDataProvidersList",
})
});
},
error => {}
)
);
}
)
);
},
},
name: "UsageStatisticsDataProvidersShow",
@ -243,7 +243,7 @@ export default {
Toolbar,
ToolbarButton,
},
}
};
</script>
<style scoped>
.active {

View File

@ -24,19 +24,19 @@
</template>
<script>
import Toolbar from "./UsageStatisticsDataProvidersToolbar.vue"
import { inject, ref } from "vue"
import { APIClient } from "../../fetch/api-client.js"
import KohaTable from "../KohaTable.vue"
import Toolbar from "./UsageStatisticsDataProvidersToolbar.vue";
import { inject, ref } from "vue";
import { APIClient } from "../../fetch/api-client.js";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const AVStore = inject("AVStore") // Left in for future permissions fixes
const { get_lib_from_av, map_av_dt_filter } = AVStore
const AVStore = inject("AVStore"); // Left in for future permissions fixes
const { get_lib_from_av, map_av_dt_filter } = AVStore;
const { setConfirmationDialog, setMessage } = inject("mainStore")
const { setConfirmationDialog, setMessage } = inject("mainStore");
const table = ref()
const table = ref();
return {
get_lib_from_av,
@ -44,7 +44,7 @@ export default {
setConfirmationDialog,
setMessage,
table,
}
};
},
data: function () {
return {
@ -59,22 +59,22 @@ export default {
// add_filters: true,
actions: {},
},
}
};
},
methods: {
async getUsageDataProviders() {
const client = APIClient.erm
const client = APIClient.erm;
await client.usage_data_providers.getAll().then(
usage_data_providers => {
this.usage_data_providers = usage_data_providers
this.initialized = true
this.usage_data_providers = usage_data_providers;
this.initialized = true;
},
error => {}
)
);
},
table_url() {
let url = "/api/v1/erm/usage_data_providers"
return url
let url = "/api/v1/erm/usage_data_providers";
return url;
},
getTableColumns() {
const columns = [
@ -84,12 +84,12 @@ export default {
searchable: true,
orderable: true,
render: function (data, type, row, meta) {
return row.name
return row.name;
},
},
]
];
const data_types = ["title", "platform", "database", "item"]
const data_types = ["title", "platform", "database", "item"];
data_types.forEach(data_type => {
columns.push(
{
@ -100,8 +100,8 @@ export default {
render: function (data, type, row, meta) {
const date = row[`earliest_${data_type}`]
? row[`earliest_${data_type}`]
: __("N/A")
return date
: __("N/A");
return date;
},
},
{
@ -112,53 +112,53 @@ export default {
render: function (data, type, row, meta) {
const date = row[`latest_${data_type}`]
? row[`latest_${data_type}`]
: __("N/A")
return date
: __("N/A");
return date;
},
}
)
})
);
});
return columns
return columns;
},
createTableHeader() {
const table = this.$refs.table.$el.getElementsByTagName("table")[0]
const table = this.$refs.table.$el.getElementsByTagName("table")[0];
const row = table.insertRow(0)
const row = table.insertRow(0);
const [cellOne, cellTwo, cellThree, cellFour, cellFive] =
Array.from("1".repeat(5)).map(item => {
const cell = document.createElement("th")
row.appendChild(cell)
return cell
})
cellTwo.colSpan = 2
cellTwo.innerHTML = this.$__("Title reports")
cellThree.colSpan = 2
cellThree.innerHTML = this.$__("Platform reports")
cellFour.colSpan = 2
cellFour.innerHTML = this.$__("Database reports")
cellFive.colSpan = 2
cellFive.innerHTML = this.$__("Item reports")
const cell = document.createElement("th");
row.appendChild(cell);
return cell;
});
cellTwo.colSpan = 2;
cellTwo.innerHTML = this.$__("Title reports");
cellThree.colSpan = 2;
cellThree.innerHTML = this.$__("Platform reports");
cellFour.colSpan = 2;
cellFour.innerHTML = this.$__("Database reports");
cellFive.colSpan = 2;
cellFive.innerHTML = this.$__("Item reports");
this.$refs.table_div.classList.remove("hide-table")
this.$refs.table_div.classList.remove("hide-table");
},
},
watch: {
table() {
// table needs to be rendered before header can be created and
// table is hidden by .hide-table until table header is created
this.createTableHeader()
this.createTableHeader();
},
},
mounted() {
if (!this.building_table) {
this.building_table = true
this.getUsageDataProviders()
this.building_table = true;
this.getUsageDataProviders();
}
},
components: { Toolbar, KohaTable },
name: "UsageStatisticsDataProvidersSummary",
}
};
</script>
<style scoped>

View File

@ -12,5 +12,5 @@
<script>
export default {
name: "UsageStatisticsDataProvidersToolbar",
}
};
</script>

View File

@ -15,17 +15,17 @@
</template>
<script>
import { APIClient } from "../../fetch/api-client.js"
import { ref } from "vue"
import KohaTable from "../KohaTable.vue"
import { APIClient } from "../../fetch/api-client.js";
import { ref } from "vue";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const table = ref()
const table = ref();
return {
table,
}
};
},
data() {
return {
@ -40,11 +40,11 @@ export default {
table_settings: this.title_table_settings,
add_filters: true,
},
}
};
},
methods: {
async getData() {
const client = APIClient.erm
const client = APIClient.erm;
await client[`usage_${this.data_type}s`]
.count({
usage_data_provider_id:
@ -52,18 +52,18 @@ export default {
})
.then(
count => {
this.data_count = count
this.initialized = true
this.data_count = count;
this.initialized = true;
},
error => {}
)
);
},
table_url() {
let url = "/api/v1/erm/usage_%ss?usage_data_provider_id=%s".format(
this.data_type,
this.$route.params.usage_data_provider_id
)
return url
);
return url;
},
getTableColumns() {
const column_options = [
@ -141,23 +141,23 @@ export default {
orderable: true,
},
},
]
];
const columns = column_options
.filter(column => column.used_by.includes(this.data_type))
.map(result => result.column)
return columns
.map(result => result.column);
return columns;
},
},
mounted() {
if (!this.building_table) {
this.building_table = true
this.getData()
this.building_table = true;
this.getData();
}
},
props: ["data_type"],
components: { KohaTable },
name: "UsageStatisticsProviderDataList",
}
};
</script>
<style scoped>

View File

@ -357,29 +357,29 @@
</template>
<script>
import ButtonSubmit from "../ButtonSubmit.vue"
import { inject } from "vue"
import { storeToRefs } from "pinia"
import { APIClient } from "../../fetch/api-client.js"
import ButtonSubmit from "../ButtonSubmit.vue";
import { inject } from "vue";
import { storeToRefs } from "pinia";
import { APIClient } from "../../fetch/api-client.js";
export default {
setup() {
const AVStore = inject("AVStore")
const AVStore = inject("AVStore");
const {
av_report_types,
av_platform_reports_metrics,
av_database_reports_metrics,
av_title_reports_metrics,
av_item_reports_metrics,
} = storeToRefs(AVStore)
} = storeToRefs(AVStore);
const { setConfirmationDialog, setMessage, setError } =
inject("mainStore")
inject("mainStore");
const { getMonthsData, getColumnOptions } = inject("reportsStore")
const { getMonthsData, getColumnOptions } = inject("reportsStore");
const months_data = getMonthsData()
const title_property_column_options = getColumnOptions()
const months_data = getMonthsData();
const title_property_column_options = getColumnOptions();
return {
av_report_types,
@ -392,7 +392,7 @@ export default {
setError,
months_data,
title_property_column_options,
}
};
},
data() {
return {
@ -479,16 +479,16 @@ export default {
request_url: null,
report_name: "",
data_type: null,
}
};
},
methods: {
async getData(query, report_type) {
const client = APIClient.erm
const client = APIClient.erm;
await client[`usage_${report_type}s`].getAll(query).then(
response => {
// If multiple searches are done we need to keep the results of the
// earlier searches but not allow for duplicate objects in the option array
const addNewData = [...this.filter_data, ...response]
const addNewData = [...this.filter_data, ...response];
const removedDuplicates = [
...new Map(
addNewData.map(object => [
@ -496,36 +496,36 @@ export default {
object,
])
).values(),
]
this.filter_data = removedDuplicates
];
this.filter_data = removedDuplicates;
},
error => {}
)
);
},
dataSearchFilter(e) {
const report_type = this.query.report_type
const data_type = this.data_type
const report_type = this.query.report_type;
const data_type = this.data_type;
if (!report_type) {
alert("Please select a report type")
alert("Please select a report type");
}
if (e.target.value.length > 1) {
const providers = this.query.usage_data_providers
? this.query.usage_data_providers
: []
const dataQueryObject = {}
dataQueryObject[data_type] = { "-like": `${e.target.value}%` }
: [];
const dataQueryObject = {};
dataQueryObject[data_type] = { "-like": `${e.target.value}%` };
if (providers.length) {
dataQueryObject.usage_data_provider_id = providers
dataQueryObject.usage_data_provider_id = providers;
}
this.getData(dataQueryObject, this.data_type)
this.getData(dataQueryObject, this.data_type);
}
},
validateYear(year) {
const validYearCheck = /^\d{4}$/.test(year) ? true : false
return validYearCheck
const validYearCheck = /^\d{4}$/.test(year) ? true : false;
return validYearCheck;
},
clearForm(e) {
e.preventDefault()
e.preventDefault();
this.query = {
data_display: "monthly",
@ -538,111 +538,111 @@ export default {
start_year: null,
end_month: null,
end_year: null,
}
this.yearly_filter_required = true
};
this.yearly_filter_required = true;
},
buildCustomReport(e) {
e.preventDefault()
e.preventDefault();
const urlParams = this.validateFormAndCreateUrlParams()
const urlParams = this.validateFormAndCreateUrlParams();
this.$router.push({
name: "UsageStatisticsReportsViewer",
query: { data: JSON.stringify(urlParams) },
})
});
},
monthSelector(e) {
if (!this.query.start_year || !this.query.end_year) {
alert(
"Please select a start and end year before choosing this option"
)
return
);
return;
}
if (e.target.id === "yearly_filter_required_no") {
const years = []
const years = [];
for (
let i = parseInt(this.query.start_year);
i <= parseInt(this.query.end_year);
i++
) {
years.push(i)
years.push(i);
}
const months = this.determineMonths(
this.query,
years,
this.months_data
)
);
this.time_period_columns_builder = months
this.yearly_filter_required = false
this.time_period_columns_builder = months;
this.yearly_filter_required = false;
} else {
this.time_period_columns_builder = null
this.yearly_filter_required = true
this.time_period_columns_builder = null;
this.yearly_filter_required = true;
}
},
determineMonths(query, years, months_data) {
const { start_month, end_month } = query
const months_per_year = {}
const numberOfYears = years.length
const { start_month, end_month } = query;
const months_per_year = {};
const numberOfYears = years.length;
years.forEach((year, index) => {
// No month parameters selected - return all months
if (!start_month && !end_month) {
const copied_months = months_data.map(month => {
return { ...month }
})
months_per_year[year] = copied_months
return
return { ...month };
});
months_per_year[year] = copied_months;
return;
}
// If a report of 3+ years is chosen, "middle" years will return all months
if (index > 0 && index + 1 < numberOfYears) {
const copied_months = months_data.map(month => {
return { ...month }
})
months_per_year[year] = copied_months
return
return { ...month };
});
months_per_year[year] = copied_months;
return;
}
// If a single year report is chosen, return the correct number of months
if (index === 0 && numberOfYears === 1) {
const months = []
const first_month = start_month ? parseInt(start_month) : 1
const last_month = end_month ? parseInt(end_month) : 12
const months = [];
const first_month = start_month ? parseInt(start_month) : 1;
const last_month = end_month ? parseInt(end_month) : 12;
for (let i = first_month; i <= last_month; i++) {
months.push(months_data[i - 1])
months.push(months_data[i - 1]);
}
months_per_year[year] = months
return
months_per_year[year] = months;
return;
}
// If a multiple year report is chosen, ensure the first year has the correct months
if (index === 0 && numberOfYears > 1) {
const months = []
const first_month = start_month ? parseInt(start_month) : 1
const months = [];
const first_month = start_month ? parseInt(start_month) : 1;
for (let i = first_month; i <= 12; i++) {
months.push(months_data[i - 1])
months.push(months_data[i - 1]);
}
months_per_year[year] = months
return
months_per_year[year] = months;
return;
}
// If a multiple year report is chosen, ensure the final year has the correct months
if (index + 1 === numberOfYears && numberOfYears > 1) {
const months = []
const last_month = end_month ? parseInt(end_month) : 12
const months = [];
const last_month = end_month ? parseInt(end_month) : 12;
for (let i = 1; i <= last_month; i++) {
months.push(months_data[i - 1])
months.push(months_data[i - 1]);
}
months_per_year[year] = months
return
months_per_year[year] = months;
return;
}
})
return months_per_year
});
return months_per_year;
},
updateMonthsRequired($event, key, index, time_period_columns) {
const value = $event.target.checked
const value = $event.target.checked;
time_period_columns[key][index].active = value
time_period_columns[key][index].active = value;
this.time_period_columns_builder = time_period_columns
this.time_period_columns_builder = time_period_columns;
},
buildMonthlyUrlQuery(
query,
@ -650,26 +650,26 @@ export default {
data_display,
db_table
) {
let url
let prefix
let url;
let prefix;
switch (data_display) {
case "monthly":
case "monthly_with_totals":
url = `/api/v1/erm/eUsage/monthly_report/${db_table}`
prefix = "erm_usage_muses"
break
url = `/api/v1/erm/eUsage/monthly_report/${db_table}`;
prefix = "erm_usage_muses";
break;
case "metric_type":
url = `/api/v1/erm/eUsage/metric_types_report/${db_table}`
prefix = "erm_usage_muses"
break
url = `/api/v1/erm/eUsage/metric_types_report/${db_table}`;
prefix = "erm_usage_muses";
break;
case "usage_data_provider":
url = `/api/v1/erm/eUsage/provider_rollup_report/${db_table}`
prefix = `erm_usage_${db_table}s.erm_usage_muses`
break
url = `/api/v1/erm/eUsage/provider_rollup_report/${db_table}`;
prefix = `erm_usage_${db_table}s.erm_usage_muses`;
break;
}
// Work out which years are included in the query
const years = []
const years = [];
const {
start_year,
end_year,
@ -678,61 +678,61 @@ export default {
usage_data_providers,
keywords,
report_type,
} = query
} = query;
for (let i = parseInt(start_year); i <= parseInt(end_year); i++) {
years.push(i)
years.push(i);
}
const months = time_period_columns
? time_period_columns
: this.determineMonths(query, years, this.months_data)
this.time_period_columns_builder = months
: this.determineMonths(query, years, this.months_data);
this.time_period_columns_builder = months;
// Build a query array by year - [{ year1 }, {year2} ...etc]
const queryArray = years.map(year => {
const queryByYear = {}
const queryByYear = {};
queryByYear[`${prefix}.year`] = year
queryByYear[`${prefix}.report_type`] = report_type
queryByYear[`${prefix}.year`] = year;
queryByYear[`${prefix}.report_type`] = report_type;
// Find the months applicable to each year, ignoring months that have been de-selected
const queryMonths = months[year]
.filter(month => month.active)
.map(month => {
return month.value
})
queryByYear[`${prefix}.month`] = queryMonths
return month.value;
});
queryByYear[`${prefix}.month`] = queryMonths;
// Add any keyword query
if (keywords) {
const object_ids = keywords.map(object => {
return object[`${db_table}_id`]
})
queryByYear[`${prefix}.${db_table}_id`] = object_ids
return object[`${db_table}_id`];
});
queryByYear[`${prefix}.${db_table}_id`] = object_ids;
}
// Add any metric types query
if (metric_types) {
queryByYear[`${prefix}.metric_type`] = metric_types
queryByYear[`${prefix}.metric_type`] = metric_types;
}
// Add any access types query
if (access_types) {
queryByYear[`${prefix}.access_type`] = access_types
queryByYear[`${prefix}.access_type`] = access_types;
}
// Add any data provider query
if (usage_data_providers) {
queryByYear[`${prefix}.usage_data_provider_id`] =
usage_data_providers
usage_data_providers;
}
return queryByYear
})
return queryByYear;
});
url += `?q=${JSON.stringify(queryArray)}`
url += `?q=${JSON.stringify(queryArray)}`;
return url
return url;
},
buildYearlyUrlQuery(query, db_table) {
let url = `/api/v1/erm/eUsage/yearly_report/${db_table}`
let url = `/api/v1/erm/eUsage/yearly_report/${db_table}`;
const {
start_year,
end_year,
@ -741,74 +741,74 @@ export default {
usage_data_providers,
keywords,
report_type,
} = query
const queryObject = {}
} = query;
const queryObject = {};
// Work out which years are included in the query
const years = []
const years = [];
for (let i = parseInt(start_year); i <= parseInt(end_year); i++) {
years.push(i)
years.push(i);
}
queryObject["erm_usage_yuses.year"] = years
this.time_period_columns_builder = years
queryObject[`erm_usage_yuses.report_type`] = report_type
queryObject["erm_usage_yuses.year"] = years;
this.time_period_columns_builder = years;
queryObject[`erm_usage_yuses.report_type`] = report_type;
// Add any metric types query
if (metric_types) {
queryObject[`erm_usage_yuses.metric_type`] = metric_types
queryObject[`erm_usage_yuses.metric_type`] = metric_types;
}
// Add any access types query
if (access_types) {
queryObject[`erm_usage_yuses.access_type`] = access_types
queryObject[`erm_usage_yuses.access_type`] = access_types;
}
// Add any keyword query
if (keywords) {
const object_ids = keywords.map(object => {
return object[`${db_table}_id`]
})
queryObject[`erm_usage_yuses.${db_table}_id`] = object_ids
return object[`${db_table}_id`];
});
queryObject[`erm_usage_yuses.${db_table}_id`] = object_ids;
}
// Add any data provider query
if (usage_data_providers) {
queryObject[`erm_usage_yuses.usage_data_provider_id`] =
usage_data_providers
usage_data_providers;
}
url += `?q=${JSON.stringify(queryObject)}`
url += `?q=${JSON.stringify(queryObject)}`;
return url
return url;
},
setMetricTypesAndProviderList(e) {
const report_type = e
const possible_metric_types = []
let av_type
const report_type = e;
const possible_metric_types = [];
let av_type;
this.filter_data.length = 0
this.query.keywords = null
this.filter_data.length = 0;
this.query.keywords = null;
if (report_type) {
switch (report_type.substring(0, 1)) {
case "P":
av_type = this.av_platform_reports_metrics
this.data_type = "platform"
break
av_type = this.av_platform_reports_metrics;
this.data_type = "platform";
break;
case "T":
av_type = this.av_title_reports_metrics
this.data_type = "title"
break
av_type = this.av_title_reports_metrics;
this.data_type = "title";
break;
case "I":
av_type = this.av_item_reports_metrics
this.data_type = "item"
break
av_type = this.av_item_reports_metrics;
this.data_type = "item";
break;
case "D":
av_type = this.av_database_reports_metrics
this.data_type = "database"
break
av_type = this.av_database_reports_metrics;
this.data_type = "database";
break;
}
if (report_type === "TR_J3" || report_type === "TR_B3") {
this.access_types_options = ["Controlled", "OA_Gold"]
this.access_types_options = ["Controlled", "OA_Gold"];
} else {
this.access_types_options = []
this.access_types_options = [];
}
for (const metric in this.metric_types_matrix) {
@ -820,108 +820,108 @@ export default {
) {
const av_metric_type = av_type.find(
type => metric === type.value
)
possible_metric_types.push(av_metric_type)
);
possible_metric_types.push(av_metric_type);
}
}
this.metric_types_options = possible_metric_types
this.metric_types_options = possible_metric_types;
// Limit usage data providers to those with the applicable report type
this.usage_data_provider_list =
this.usage_data_providers.filter(provider => {
const report_types = provider.report_types
const single_report_types = report_types.split(";")
single_report_types.pop()
const report_types = provider.report_types;
const single_report_types = report_types.split(";");
single_report_types.pop();
return single_report_types.includes(report_type)
})
return single_report_types.includes(report_type);
});
// Unselect any additional columns that aren't applicable to this data_type
const title_properties = Object.keys(
this.title_property_column_options
)
title_properties.shift() // Remove the first column as this is a default
);
title_properties.shift(); // Remove the first column as this is a default
title_properties.forEach(prop => {
if (
!this.title_property_column_options[
prop
].used_by.includes(this.data_type)
) {
this.title_property_column_options[prop].active = false
this.title_property_column_options[prop].active = false;
}
})
});
} else {
this.metric_types_options = []
this.query.metric_types = null
this.metric_types_options = [];
this.query.metric_types = null;
// Reset data providers to include all providers
this.usage_data_provider_list = [...this.usage_data_providers]
this.usage_data_provider_list = [...this.usage_data_providers];
}
},
setReportTypesAndResetFilterData(providers) {
const permittedReportTypes = []
const permittedReportTypes = [];
if (providers.length === 0) {
this.report_types_options = this.av_report_types
this.query.keywords = null
this.filter_data.length = 0
return
this.report_types_options = this.av_report_types;
this.query.keywords = null;
this.filter_data.length = 0;
return;
}
providers.forEach(id => {
const data_provider = this.usage_data_providers.find(
item => item.erm_usage_data_provider_id === id
)
const report_types = data_provider.report_types
const single_report_types = report_types.split(";")
single_report_types.pop() // remove trailing "" from array
);
const report_types = data_provider.report_types;
const single_report_types = report_types.split(";");
single_report_types.pop(); // remove trailing "" from array
single_report_types.forEach(type => {
const report_type = this.av_report_types.find(
rt => rt.value === type
)
permittedReportTypes.push(report_type)
})
);
permittedReportTypes.push(report_type);
});
// If we change/remove a data provider then we don't want data being displayed from that provider in the dropdown
const removeProviderData = this.filter_data.filter(
obj => obj.erm_usage_data_provider_id !== id
)
this.filter_data = removeProviderData
})
this.report_types_options = permittedReportTypes
);
this.filter_data = removeProviderData;
});
this.report_types_options = permittedReportTypes;
},
defineColumns(title_props) {
const columns = []
const columns = [];
// Add user selected columns
const title_properties = Object.keys(title_props)
const title_properties = Object.keys(title_props);
title_properties.forEach(prop => {
if (title_props[prop].active) {
columns.push(title_props[prop].id)
columns.push(title_props[prop].id);
}
})
});
return columns
return columns;
},
async saveToDefaultReports(e) {
e.preventDefault()
e.preventDefault();
if (!this.report_name) {
alert("Please provide a report name")
return
alert("Please provide a report name");
return;
}
const params = this.validateFormAndCreateUrlParams()
const params = this.validateFormAndCreateUrlParams();
const report = {
report_name: this.report_name,
report_url_params: JSON.stringify(params),
}
};
const client = APIClient.erm
const client = APIClient.erm;
await client.default_usage_reports.create(report).then(
success => {
this.setMessage(this.$__("Report saved successfully"))
this.setMessage(this.$__("Report saved successfully"));
},
error => {}
)
);
},
validateFormAndCreateUrlParams() {
const queryObject = { ...this.query }
const queryObject = { ...this.query };
const {
start_year,
end_year,
@ -929,34 +929,34 @@ export default {
report_type,
metric_types,
access_types,
} = queryObject
} = queryObject;
if (!report_type || !start_year || !end_year) {
alert(
"You have not filled in all the required fields, please try again"
)
return
);
return;
}
// validate if the year is a valid string
const valid_start_year = this.validateYear(start_year)
const valid_end_year = this.validateYear(end_year)
const valid_start_year = this.validateYear(start_year);
const valid_end_year = this.validateYear(end_year);
if (!valid_start_year || !valid_end_year) {
this.setError(
this.$__("Please enter a year with the format YYYY")
)
return
);
return;
}
// If no metric types are selected then all possible values should be included for backend data filtering
if (!metric_types || (metric_types && metric_types.length === 0)) {
const final_metric_types = this.metric_types_options.map(
metric => {
return metric.value
return metric.value;
}
)
queryObject.metric_types = final_metric_types
);
queryObject.metric_types = final_metric_types;
}
// If no access types are selected then all possible values should be included for backend data filtering ( but only for TR_J3 and TR_B3 reports)
if (
@ -965,10 +965,10 @@ export default {
) {
const final_access_types = this.access_types_options.map(
access => {
return access
return access;
}
)
queryObject.access_types = final_access_types
);
queryObject.access_types = final_access_types;
}
// Determine which database table should be queried
@ -979,15 +979,15 @@ export default {
data_display,
this.data_type
)
: this.buildYearlyUrlQuery(queryObject, this.data_type)
const type = data_display
: this.buildYearlyUrlQuery(queryObject, this.data_type);
const type = data_display;
const columns =
data_display === "usage_data_provider"
? []
: this.defineColumns(this.title_property_column_options)
: this.defineColumns(this.title_property_column_options);
const yearly_filter = data_display.includes("monthly")
? this.yearly_filter_required
: false
: false;
const urlParams = {
url,
@ -996,16 +996,16 @@ export default {
yearly_filter,
type,
tp_columns: this.time_period_columns_builder,
}
};
return urlParams
return urlParams;
},
},
props: ["usage_data_providers"],
components: {
ButtonSubmit,
},
}
};
</script>
<style scoped>

View File

@ -44,22 +44,22 @@
</template>
<script>
import { inject } from "vue"
import ButtonSubmit from "../ButtonSubmit.vue"
import { APIClient } from "../../fetch/api-client.js"
import UsageStatisticsReportBuilder from "./UsageStatisticsReportBuilder.vue"
import UsageStatisticsSavedReports from "./UsageStatisticsSavedReports.vue"
import { inject } from "vue";
import ButtonSubmit from "../ButtonSubmit.vue";
import { APIClient } from "../../fetch/api-client.js";
import UsageStatisticsReportBuilder from "./UsageStatisticsReportBuilder.vue";
import UsageStatisticsSavedReports from "./UsageStatisticsSavedReports.vue";
export default {
setup() {
const { setConfirmationDialog, setMessage, setError } =
inject("mainStore")
inject("mainStore");
return {
setConfirmationDialog,
setMessage,
setError,
}
};
},
data() {
return {
@ -68,16 +68,16 @@ export default {
default_usage_report: null,
default_usage_reports: [],
usage_data_providers: [],
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getUsageDataProviders()
})
vm.getUsageDataProviders();
});
},
methods: {
async getUsageDataProviders() {
const client = APIClient.erm
const client = APIClient.erm;
await client.usage_data_providers.getAll().then(
usage_data_providers => {
if (usage_data_providers.length === 0) {
@ -85,16 +85,16 @@ export default {
this.$__(
"No data providers have been created - no report data will be available"
)
)
);
}
this.usage_data_providers = usage_data_providers
this.initialized = true
this.usage_data_providers = usage_data_providers;
this.initialized = true;
},
error => {}
)
);
},
changeCustomOrDefault(e) {
this.custom_or_default = e.target.getAttribute("data-content")
this.custom_or_default = e.target.getAttribute("data-content");
},
},
components: {
@ -103,7 +103,7 @@ export default {
UsageStatisticsSavedReports,
},
name: "UsageStatisticsReportsHome",
}
};
</script>
<style scoped>

View File

@ -24,65 +24,65 @@
</template>
<script>
import { inject, ref } from "vue"
import KohaTable from "../KohaTable.vue"
import { inject, ref } from "vue";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const table = ref()
const table = ref();
const { getMonthsData, getColumnOptions, checkReportColumns } =
inject("reportsStore")
inject("reportsStore");
return {
getMonthsData,
getColumnOptions,
checkReportColumns,
table,
}
};
},
beforeCreate() {
const urlParams = JSON.parse(this.$route.query.data)
this.params = urlParams
this.report_type = this.params.type
let data_type
const urlParams = JSON.parse(this.$route.query.data);
this.params = urlParams;
this.report_type = this.params.type;
let data_type;
switch (this.params.queryObject.report_type.substring(0, 1)) {
case "P":
data_type = "platform"
break
data_type = "platform";
break;
case "T":
data_type = "title"
break
data_type = "title";
break;
case "I":
data_type = "item"
break
data_type = "item";
break;
case "D":
data_type = "database"
break
data_type = "database";
break;
}
this.data_type = data_type
this.data_type = data_type;
this.embed =
this.report_type === "yearly"
? ["erm_usage_yuses"]
: ["erm_usage_muses"]
: ["erm_usage_muses"];
switch (this.report_type) {
case "monthly":
case "monthly_with_totals":
this.embed = "erm_usage_muses"
break
this.embed = "erm_usage_muses";
break;
case "yearly":
this.embed = "erm_usage_yuses"
break
this.embed = "erm_usage_yuses";
break;
case "metric_type":
this.embed = "erm_usage_muses"
break
this.embed = "erm_usage_muses";
break;
case "usage_data_provider":
this.embed = `erm_usage_${data_type}s.erm_usage_muses`
break
this.embed = `erm_usage_${data_type}s.erm_usage_muses`;
break;
}
this.years = Object.keys(this.params.tp_columns)
this.year = this.years[this.years.length - 1]
this.years = Object.keys(this.params.tp_columns);
this.year = this.years[this.years.length - 1];
},
data() {
return {
@ -105,24 +105,24 @@ export default {
params: this.params,
year: this.year,
years: this.years,
}
};
},
methods: {
buildColumnArray(report_display, params, data_type) {
const columns = params.columns
const months_data = this.getMonthsData()
const column_options = this.getColumnOptions()
const time_period_columns = params.tp_columns
const yearly_filter = params.yearly_filter
const query = params.queryObject
const report_type = params.queryObject.report_type
const column_set = []
const columns = params.columns;
const months_data = this.getMonthsData();
const column_options = this.getColumnOptions();
const time_period_columns = params.tp_columns;
const yearly_filter = params.yearly_filter;
const query = params.queryObject;
const report_type = params.queryObject.report_type;
const column_set = [];
columns.forEach(column => {
column_set.push(column_options[column].column)
column_set.push(column_options[column].column);
// Reset all columns except data providers to inactive
if (column !== 1) column_options[column].active = false
})
if (column !== 1) column_options[column].active = false;
});
report_display !== "usage_data_provider" &&
column_set.unshift({
@ -132,7 +132,7 @@ export default {
data: data_type,
searchable: true,
orderable: true,
})
});
// Add metric type to each row
if (report_display !== "metric_type") {
@ -143,7 +143,7 @@ export default {
data: "yop",
searchable: true,
orderable: true,
})
});
}
// Add access type if it is required
if (this.checkReportColumns(report_type, "Access_Type")) {
@ -152,16 +152,16 @@ export default {
data: "access_type",
searchable: true,
orderable: true,
})
});
}
column_set.push({
title: __("Metric"),
render: function (data, type, row, meta) {
return row.metric_type
return row.metric_type;
},
searchable: true,
orderable: true,
})
});
}
if (report_display === "usage_data_provider") {
@ -170,14 +170,14 @@ export default {
data: "name",
searchable: true,
orderable: true,
})
});
column_set.push({
title: __("Period total"),
data: "provider_rollup_total",
searchable: true,
orderable: true,
})
return column_set
});
return column_set;
}
// Add monthly columns
@ -189,28 +189,28 @@ export default {
const find_correct_month =
row.erm_usage_muses.filter(
item => item.month === month.value
)
const usage_record = find_correct_month.length
);
const usage_record = find_correct_month.length;
const usage = usage_record
? find_correct_month[0].usage_count
: "-"
return usage
: "-";
return usage;
},
searchable: true,
orderable: true,
})
})
});
});
} else {
if (report_display.includes("monthly")) {
const years = Object.keys(time_period_columns)
const years = Object.keys(time_period_columns);
years.forEach(year => {
const abbreviated_year = year.substring(2)
const selected_months = time_period_columns[year]
const abbreviated_year = year.substring(2);
const selected_months = time_period_columns[year];
selected_months.forEach(month => {
if (month.active) {
const column_title = `${month.short}${abbreviated_year}`
const column_title = `${month.short}${abbreviated_year}`;
column_set.push({
title: __(column_title),
render: function (data, type, row, meta) {
@ -218,51 +218,51 @@ export default {
row.erm_usage_muses.filter(
item =>
item.year === parseInt(year)
)
);
const find_correct_month =
filtered_by_year.filter(
item =>
item.month === month.value
)
);
const data_available =
find_correct_month.length
find_correct_month.length;
const usage = data_available
? find_correct_month[0].usage_count
: "-"
return usage
: "-";
return usage;
},
searchable: true,
orderable: true,
})
});
}
})
})
});
});
}
if (report_display === "yearly") {
const years = time_period_columns
const years = time_period_columns;
years.forEach(year => {
const title = String(year)
const title = String(year);
column_set.push({
title: __(title),
render: function (data, type, row, meta) {
const find_usage = row.erm_usage_yuses.find(
item => item.year === year
)
);
const usage = find_usage
? find_usage.totalcount
: "-"
return usage
: "-";
return usage;
},
searchable: true,
orderable: true,
})
})
});
});
}
if (report_display === "metric_type") {
const metric_types = query.metric_types
const access_types = query.access_types
const metric_types = query.metric_types;
const access_types = query.access_types;
// Add yop if it is required
if (this.checkReportColumns(report_type, "YOP")) {
column_set.push({
@ -270,7 +270,7 @@ export default {
data: "yop",
searchable: true,
orderable: true,
})
});
}
metric_types.forEach(metric => {
if (access_types && access_types.length > 0) {
@ -282,27 +282,27 @@ export default {
row.erm_usage_muses.filter(
item =>
item.access_type === access
)
);
const filterByMetric =
filterByType.filter(
item =>
item.metric_type === metric
)
);
const period_total =
filterByMetric.reduce(
(acc, item) => {
return (
acc + item.usage_count
)
);
},
0
)
return period_total
);
return period_total;
},
searchable: false,
orderable: false,
})
})
});
});
} else {
column_set.push({
title: __(metric),
@ -310,20 +310,20 @@ export default {
const filterByMetric =
row.erm_usage_muses.filter(
item => item.metric_type === metric
)
);
const period_total = filterByMetric.reduce(
(acc, item) => {
return acc + item.usage_count
return acc + item.usage_count;
},
0
)
return period_total
);
return period_total;
},
searchable: false,
orderable: false,
})
});
}
})
});
}
}
// Add totals column if required
@ -333,180 +333,181 @@ export default {
data: "usage_total",
searchable: true,
orderable: true,
})
});
}
return column_set
return column_set;
},
async update_table() {
this.$refs.table.redraw(this.tableURL(this.year, this.params))
this.$refs.table.redraw(this.tableURL(this.year, this.params));
},
buildFilteredQuery(query, time_period_columns, year) {
const queryObject = {}
const queryObject = {};
const {
metric_types,
access_types,
usage_data_providers,
keywords,
report_type,
} = query
let data_type
} = query;
let data_type;
switch (report_type.substring(0, 1)) {
case "P":
data_type = "platform"
break
data_type = "platform";
break;
case "T":
data_type = "title"
break
data_type = "title";
break;
case "I":
data_type = "item"
break
data_type = "item";
break;
case "D":
data_type = "database"
break
data_type = "database";
break;
}
let url = `/api/v1/erm/eUsage/monthly_report/${data_type}`
let url = `/api/v1/erm/eUsage/monthly_report/${data_type}`;
// Identify the year
queryObject[`erm_usage_muses.year`] = year
queryObject[`erm_usage_muses.report_type`] = report_type
queryObject[`erm_usage_muses.year`] = year;
queryObject[`erm_usage_muses.report_type`] = report_type;
// Add months to query
const months = time_period_columns[year].map(month => {
return month.value
})
queryObject[`erm_usage_muses.month`] = months
return month.value;
});
queryObject[`erm_usage_muses.month`] = months;
// Add any keyword query
if (keywords) {
const object_ids = keywords.map(object => {
return object[`${data_type}_id`]
})
queryObject[`erm_usage_muses.${data_type}_id`] = object_ids
return object[`${data_type}_id`];
});
queryObject[`erm_usage_muses.${data_type}_id`] = object_ids;
}
// Add any metric types query
if (metric_types) {
queryObject[`erm_usage_muses.metric_type`] = metric_types
queryObject[`erm_usage_muses.metric_type`] = metric_types;
}
// Add any metric types query
if (access_types) {
queryObject[`erm_usage_muses.access_type`] = access_types
queryObject[`erm_usage_muses.access_type`] = access_types;
}
// Add any data provider query
if (usage_data_providers) {
queryObject[`erm_usage_muses.usage_data_provider_id`] =
usage_data_providers
usage_data_providers;
}
url += `?q=[${JSON.stringify(queryObject)}]`
url += `?q=[${JSON.stringify(queryObject)}]`;
return url
return url;
},
tableURL(year, params) {
const filter_required = params.yearly_filter
const filter_required = params.yearly_filter;
if (filter_required) {
const query = params.queryObject
const time_period_columns = params.tp_columns
const query = params.queryObject;
const time_period_columns = params.tp_columns;
const url = this.buildFilteredQuery(
query,
time_period_columns,
year
)
);
return url
return url;
} else {
const url = params.url
const url = params.url;
return url
return url;
}
},
mergeTitleDataIntoOneLine(numberOfMetricTypes, numberOfAccessTypes) {
let dt = this.$refs.table.useTableObject()
let dt = this.$refs.table.useTableObject();
dt.on("draw", () => {
const rows = dt.rows().nodes().to$()
const rows = dt.rows().nodes().to$();
const numberOfRows = numberOfAccessTypes
? numberOfMetricTypes * numberOfAccessTypes
: numberOfMetricTypes
const data_rows = []
: numberOfMetricTypes;
const data_rows = [];
for (let i = 0; i < rows.length; i = i + numberOfRows) {
data_rows.push([rows.slice(i, i + numberOfRows)])
data_rows.push([rows.slice(i, i + numberOfRows)]);
}
data_rows
.map(item => item[0])
.forEach(titleRows => {
Array.from(titleRows).forEach((row, i) => {
const cells = row.cells
const cells = row.cells;
if (i === 0) {
cells[0].rowSpan = numberOfRows
cells[0].style.textAlign = "center"
cells[0].style.verticalAlign = "middle"
cells[0].style.borderRight = "1px solid #BCBCBC"
cells[0].rowSpan = numberOfRows;
cells[0].style.textAlign = "center";
cells[0].style.verticalAlign = "middle";
cells[0].style.borderRight =
"1px solid #BCBCBC";
} else {
cells[0].remove()
cells[0].remove();
}
})
})
})
this.$refs.table_div.classList.remove("hide-table")
});
});
});
this.$refs.table_div.classList.remove("hide-table");
},
createMetricReportTableHeader(metric_types, access_types) {
const table = this.$refs.table.$el.getElementsByTagName("table")[0]
const numberOfColumns = table.rows[0].cells.length
const dataColumns = metric_types.length * access_types
const numberOfNonStatisticColumns = numberOfColumns - dataColumns
const table = this.$refs.table.$el.getElementsByTagName("table")[0];
const numberOfColumns = table.rows[0].cells.length;
const dataColumns = metric_types.length * access_types;
const numberOfNonStatisticColumns = numberOfColumns - dataColumns;
const numberOfCellsToCreate =
numberOfNonStatisticColumns + metric_types.length
numberOfNonStatisticColumns + metric_types.length;
const row = table.insertRow(0)
const cellsToInsert = Array.from("1".repeat(numberOfCellsToCreate))
const row = table.insertRow(0);
const cellsToInsert = Array.from("1".repeat(numberOfCellsToCreate));
const cells = cellsToInsert.map(item => {
const cell = document.createElement("th")
row.appendChild(cell)
return cell
})
const cell = document.createElement("th");
row.appendChild(cell);
return cell;
});
const metricTypeColumns = cells.splice(numberOfNonStatisticColumns)
const metricTypeColumns = cells.splice(numberOfNonStatisticColumns);
metric_types.forEach((metric, i) => {
const cell = metricTypeColumns[i]
cell.colSpan = access_types
cell.innerHTML = metric
})
this.$refs.table_div.classList.remove("hide-table")
const cell = metricTypeColumns[i];
cell.colSpan = access_types;
cell.innerHTML = metric;
});
this.$refs.table_div.classList.remove("hide-table");
},
},
watch: {
table() {
const number_of_access_types = this.params.queryObject.access_types
? this.params.queryObject.access_types.length
: 0
: 0;
if (this.report_type === "metric_type") {
if (number_of_access_types) {
this.createMetricReportTableHeader(
this.params.queryObject.metric_types,
number_of_access_types
)
);
} else {
this.$refs.table_div.classList.remove("hide-table")
this.$refs.table_div.classList.remove("hide-table");
}
} else {
this.mergeTitleDataIntoOneLine(
this.params.queryObject.metric_types.length,
number_of_access_types
)
);
}
},
},
mounted() {
if (!this.building_table) {
this.yearly_filter = this.params.yearly_filter
this.building_table = true
this.initialized = true
this.yearly_filter = this.params.yearly_filter;
this.building_table = true;
this.initialized = true;
}
},
components: {
KohaTable,
},
name: "UsageStatisticsReportsViewer",
}
};
</script>
<style scoped>

View File

@ -56,74 +56,76 @@
</template>
<script>
import ButtonSubmit from "../ButtonSubmit.vue"
import { APIClient } from "../../fetch/api-client.js"
import { inject } from "vue"
import ButtonSubmit from "../ButtonSubmit.vue";
import { APIClient } from "../../fetch/api-client.js";
import { inject } from "vue";
export default {
setup() {
const { setMessage, setError } = inject("mainStore")
const { setMessage, setError } = inject("mainStore");
return {
setMessage,
setError,
}
};
},
data() {
return {
initialized: false,
default_usage_report: null,
default_usage_reports: [],
}
};
},
mounted() {
this.getDefaultUsageReports()
this.getDefaultUsageReports();
},
methods: {
async getDefaultUsageReports() {
const client = APIClient.erm
const client = APIClient.erm;
await client.default_usage_reports.getAll().then(
default_usage_reports => {
this.default_usage_reports = default_usage_reports
this.initialized = true
this.default_usage_reports = default_usage_reports;
this.initialized = true;
},
error => {}
)
);
},
async deleteSavedReport(e) {
e.preventDefault()
const id = this.default_usage_report.erm_default_usage_report_id
e.preventDefault();
const id = this.default_usage_report.erm_default_usage_report_id;
if (id) {
const client = APIClient.erm
const client = APIClient.erm;
await client.default_usage_reports.delete(id).then(
success => {
this.setMessage(this.$__("Report deleted successfully"))
this.setMessage(
this.$__("Report deleted successfully")
);
this.default_usage_reports =
this.default_usage_reports.filter(
report =>
report.erm_default_usage_report_id !== id
)
this.default_usage_report = null
);
this.default_usage_report = null;
},
error => {}
)
);
} else {
this.setError(
this.$__("No report was selected - could not delete")
)
);
}
},
displayDefaultReport(e) {
e.preventDefault()
e.preventDefault();
this.$router.push({
name: "UsageStatisticsReportsViewer",
query: { data: this.default_usage_report.report_url_params },
})
});
},
},
components: {
ButtonSubmit,
},
name: "UsageStatisticsSaveReports",
}
};
</script>

View File

@ -67,7 +67,7 @@
</template>
<script>
import { APIClient } from "../../fetch/api-client.js"
import { APIClient } from "../../fetch/api-client.js";
export default {
name: "UserRoles",
@ -78,8 +78,8 @@ export default {
},
beforeCreate() {
this.user_roles.forEach(u => {
u.patron_str = $patron_to_html(u.patron)
})
u.patron_str = $patron_to_html(u.patron);
});
},
methods: {
addUser() {
@ -87,10 +87,10 @@ export default {
user_id: null,
role: null,
patron_str: "",
})
});
},
deleteUser(counter) {
this.user_roles.splice(counter, 1)
this.user_roles.splice(counter, 1);
},
selectUser(counter) {
// This is a bit dirty, the "select user" window should be rewritten and be a Vue component
@ -99,23 +99,23 @@ export default {
"hidden.bs.modal",
"#patron_search_modal",
this.newUserSelected
)
this.selected_user_counter = counter
);
this.selected_user_counter = counter;
},
newUserSelected(e) {
let c = this.selected_user_counter
let c = this.selected_user_counter;
let selected_patron_id =
document.getElementById("selected_patron_id").value
let patron
const client = APIClient.patron
document.getElementById("selected_patron_id").value;
let patron;
const client = APIClient.patron;
// FIXME We are missing a "loading..."
client.patrons.get(selected_patron_id).then(p => {
patron = p
this.user_roles[c].patron = patron
this.user_roles[c].patron_str = $patron_to_html(patron)
this.user_roles[c].user_id = patron.patron_id
})
patron = p;
this.user_roles[c].patron = patron;
this.user_roles[c].patron_str = $patron_to_html(patron);
this.user_roles[c].user_id = patron.patron_id;
});
},
},
}
};
</script>

View File

@ -14,13 +14,13 @@
</template>
<script>
import { inject } from "vue"
import { storeToRefs } from "pinia"
import { inject } from "vue";
import { storeToRefs } from "pinia";
export default {
setup() {
const vendorStore = inject("vendorStore")
const { vendors } = storeToRefs(vendorStore)
return { vendors }
const vendorStore = inject("vendorStore");
const { vendors } = storeToRefs(vendorStore);
return { vendors };
},
computed: {
vendorOptions() {
@ -31,7 +31,7 @@ export default {
(v.aliases.length > 0
? " (" + v.aliases.map(a => a.alias).join(", ") + ")"
: ""),
}))
}));
},
},
methods: {
@ -40,8 +40,8 @@ export default {
(vendor.full_search || "")
.toLocaleLowerCase()
.indexOf(search.toLocaleLowerCase()) > -1
)
);
},
},
}
};
</script>

View File

@ -31,7 +31,7 @@
</template>
<script>
import { APIClient } from "../fetch/api-client.js"
import { APIClient } from "../fetch/api-client.js";
export default {
props: {
@ -53,35 +53,35 @@ export default {
data: [this.selectedData],
paginationRequired: false,
selectedOptionLabel: this.selectedData[this.label],
}
};
},
computed: {
model: {
get() {
return this.modelValue
return this.modelValue;
},
set(value) {
this.$emit("update:modelValue", value)
this.$emit("update:modelValue", value);
},
},
filtered() {
return this.data.filter(item =>
item[this.label].includes(this.search)
)
);
},
paginated() {
return this.filtered.slice(0, this.limit)
return this.filtered.slice(0, this.limit);
},
hasNextPage() {
return this.paginated.length < this.filtered.length
return this.paginated.length < this.filtered.length;
},
},
mounted() {
this.observer = new IntersectionObserver(this.infiniteScroll)
this.observer = new IntersectionObserver(this.infiniteScroll);
},
methods: {
async fetchInitialData(dataType) {
const client = APIClient.erm
const client = APIClient.erm;
await client[dataType]
.getAll(
{},
@ -93,62 +93,62 @@ export default {
)
.then(
items => {
this.data = items
this.search = ""
this.limit = 19
this.scrollPage = 1
this.data = items;
this.search = "";
this.limit = 19;
this.scrollPage = 1;
},
error => {}
)
);
},
async searchFilter(e) {
if (e) {
this.paginationRequired = false
this.observer.disconnect()
this.data = []
this.search = e
const client = APIClient.erm
const attribute = "me." + this.label
const q = {}
q[attribute] = { like: `%${e}%` }
this.paginationRequired = false;
this.observer.disconnect();
this.data = [];
this.search = e;
const client = APIClient.erm;
const attribute = "me." + this.label;
const q = {};
q[attribute] = { like: `%${e}%` };
await client[this.dataType]
.getAll(q, {
_per_page: -1,
})
.then(
items => {
this.data = [...items]
this.data = [...items];
},
error => {}
)
);
} else {
this.resetSelect()
this.resetSelect();
}
},
async onOpen() {
this.paginationRequired = true
await this.fetchInitialData(this.dataType)
this.paginationRequired = true;
await this.fetchInitialData(this.dataType);
if (this.hasNextPage) {
await this.$nextTick()
this.observer.observe(this.$refs.load)
await this.$nextTick();
this.observer.observe(this.$refs.load);
}
},
onClose() {
this.observer.disconnect()
this.observer.disconnect();
},
onSelected(option) {
this.selectedOptionLabel = option[this.label]
this.selectedOptionLabel = option[this.label];
},
async infiniteScroll([{ isIntersecting, target }]) {
setTimeout(async () => {
if (isIntersecting) {
const ul = target.offsetParent
const scrollTop = target.offsetParent.scrollTop
this.limit += 20
this.scrollPage++
await this.$nextTick()
const client = APIClient.erm
ul.scrollTop = scrollTop
const ul = target.offsetParent;
const scrollTop = target.offsetParent.scrollTop;
this.limit += 20;
this.scrollPage++;
await this.$nextTick();
const client = APIClient.erm;
ul.scrollTop = scrollTop;
await client[this.dataType]
.getAll(
{},
@ -160,27 +160,27 @@ export default {
)
.then(
items => {
const existingData = [...this.data]
this.data = [...existingData, ...items]
const existingData = [...this.data];
this.data = [...existingData, ...items];
},
error => {}
)
ul.scrollTop = scrollTop
);
ul.scrollTop = scrollTop;
}
}, 250)
}, 250);
},
async resetSelect() {
if (this.$refs.select.open) {
await this.fetchInitialData(this.dataType)
await this.fetchInitialData(this.dataType);
if (this.hasNextPage) {
await this.$nextTick()
this.observer.observe(this.$refs.load)
await this.$nextTick();
this.observer.observe(this.$refs.load);
}
} else {
this.paginationRequired = false
this.paginationRequired = false;
}
},
},
name: "InfiniteScrollSelect",
}
};
</script>

View File

@ -10,14 +10,14 @@
</template>
<script>
import DataTable from "datatables.net-vue3"
import DataTablesLib from "datatables.net"
import "datatables.net-buttons"
import "datatables.net-buttons/js/buttons.html5"
import "datatables.net-buttons/js/buttons.print"
import "datatables.net-buttons/js/buttons.colVis"
import DataTable from "datatables.net-vue3";
import DataTablesLib from "datatables.net";
import "datatables.net-buttons";
import "datatables.net-buttons/js/buttons.html5";
import "datatables.net-buttons/js/buttons.print";
import "datatables.net-buttons/js/buttons.colVis";
DataTable.use(DataTablesLib)
DataTable.use(DataTablesLib);
export default {
name: "KohaTable",
@ -25,24 +25,24 @@ export default {
let buttons = _dt_buttons({
settings: this.options,
table_settings: this.table_settings,
})
});
if (this.add_filters) {
this.options.orderCellsTop = true
this.options.orderCellsTop = true;
}
if (this.table_settings) {
let state_settings = _dt_save_restore_state(this.table_settings)
this.options.stateSave = state_settings.stateSave
this.options.stateSaveCallback = state_settings.stateSaveCallback
this.options.stateLoadCallback = state_settings.stateLoadCallback
let state_settings = _dt_save_restore_state(this.table_settings);
this.options.stateSave = state_settings.stateSave;
this.options.stateSaveCallback = state_settings.stateSaveCallback;
this.options.stateLoadCallback = state_settings.stateLoadCallback;
if (
this.table_settings.hasOwnProperty("default_display_length") &&
this.table_settings.default_display_length != null
) {
this.options.pageLength =
this.table_settings.default_display_length
this.table_settings.default_display_length;
}
if (
this.table_settings.hasOwnProperty("default_sort_order") &&
@ -50,7 +50,7 @@ export default {
) {
this.options.order = [
[this.table_settings.default_sort_order, "asc"],
]
];
}
}
@ -78,26 +78,26 @@ export default {
targets: "_all",
render: function (data, type, row, meta) {
if (type == "display") {
return escape_str(data)
return escape_str(data);
}
return data
return data;
},
},
],
...this.options,
},
}
};
},
setup() {
return { dataTablesDefaults }
return { dataTablesDefaults };
},
methods: {
redraw: function (url) {
this.$refs.table.dt().ajax.url(url).draw()
this.$refs.table.dt().ajax.url(url).draw();
},
useTableObject: function () {
let dt = this.$refs.table.dt()
return dt
let dt = this.$refs.table.dt();
return dt;
},
},
beforeMount() {
@ -112,10 +112,10 @@ export default {
field.field_id ==
searchable_field.extended_attribute_type_id
)
.map(el => el.value_str)
}
return _render
})(searchable_field)
.map(el => el.value_str);
};
return _render;
})(searchable_field);
this.tableColumns.push({
name: searchable_field.name,
@ -133,24 +133,24 @@ export default {
searchable: true,
sortable: false,
render: _customRender,
})
});
if (searchable_field.authorised_value_category_name) {
let options =
this.searchable_av_options[
searchable_field.authorised_value_category_name
]
];
options.map(e => {
e["_id"] = e["value"]
e["_str"] = e["label"]
return e
})
e["_id"] = e["value"];
e["_str"] = e["label"];
return e;
});
this.filters_options[this.tableColumns.length - 1] =
options
options;
}
})
});
}
this.tableColumns = [
@ -162,100 +162,100 @@ export default {
searchable: false,
sortable: false,
render: (data, type, row) => {
let content = []
let content = [];
this.actions["-1"].forEach(action => {
if (typeof action === "object") {
let action_name = Object.keys(action)[0]
let should_display = true
let action_name = Object.keys(action)[0];
let should_display = true;
if (
typeof action[action_name]
.should_display === "function"
) {
should_display =
action[action_name].should_display(row)
action[action_name].should_display(row);
}
if (should_display) {
content.push(
`<a class="${action_name} btn btn-default btn-xs" role="button"><i class="${action[action_name].icon}"></i> ${action[action_name].text}</a>`
)
);
}
} else if (action == "edit") {
content.push(
'<a class="edit btn btn-default btn-xs" role="button"><i class="fa fa-pencil"></i> ' +
this.$__("Edit") +
"</a>"
)
);
} else if (action == "delete") {
content.push(
'<a class="delete btn btn-default btn-xs" role="button"><i class="fa fa-trash"></i> ' +
this.$__("Delete") +
"</a>"
)
);
} else if (action == "remove") {
content.push(
'<a class="remove btn btn-default btn-xs" role="button"><i class="fa fa-remove"></i> ' +
this.$__("Remove") +
"</a>"
)
);
}
})
return content.join(" ")
});
return content.join(" ");
},
},
]
];
}
},
mounted() {
let dt = this.$refs.table.dt()
let table_node = dt.table().node()
let add_filters = this.add_filters
let filters_options = this.filters_options
let dt = this.$refs.table.dt();
let table_node = dt.table().node();
let add_filters = this.add_filters;
let filters_options = this.filters_options;
if (add_filters) {
_dt_add_filters(table_node, dt, filters_options)
_dt_add_filters(table_node, dt, filters_options);
}
dt.on("column-visibility.dt", function () {
if (add_filters) {
_dt_add_filters(table_node, dt, filters_options)
_dt_add_filters(table_node, dt, filters_options);
}
})
});
dt.on("search.dt", function (e, settings) {
toggledClearFilter(
settings.oPreviousSearch.sSearch,
settings.nTable.id
)
})
);
});
if (Object.keys(this.actions).length) {
const self = this
const self = this;
dt.on("draw", () => {
const dataSet = dt.rows().data()
const dataSet = dt.rows().data();
Object.entries(this.actions).forEach(([col_id, actions]) => {
dt.column(col_id)
.nodes()
.to$()
.each(function (idx) {
const data = dataSet[idx]
const data = dataSet[idx];
actions.forEach(action => {
let action_name =
typeof action === "object"
? Object.keys(action)[0]
: action
: action;
$("." + action_name, this).on("click", e => {
self.$emit(action_name, data, dt, e)
})
})
})
})
})
self.$emit(action_name, data, dt, e);
});
});
});
});
});
}
},
beforeUnmount() {
const dt = this.$refs.table.dt()
dt.destroy()
const dt = this.$refs.table.dt();
dt.destroy();
},
components: {
DataTable,
@ -304,5 +304,5 @@ export default {
default: [],
},
},
}
};
</script>

View File

@ -16,25 +16,25 @@
</template>
<script>
import { inject } from "vue"
import NavigationItem from "./NavigationItem.vue"
import { inject } from "vue";
import NavigationItem from "./NavigationItem.vue";
export default {
name: "LeftMenu",
data() {
return {
navigationTree: this.leftNavigation,
}
};
},
setup: () => {
const navigationStore = inject("navigationStore")
const { leftNavigation } = navigationStore
const navigationStore = inject("navigationStore");
const { leftNavigation } = navigationStore;
return {
leftNavigation,
}
};
},
async beforeMount() {
if (this.condition)
this.navigationTree = await this.condition(this.navigationTree)
this.navigationTree = await this.condition(this.navigationTree);
},
props: {
title: String,
@ -43,7 +43,7 @@ export default {
components: {
NavigationItem,
},
}
};
</script>
<style scoped>

View File

@ -56,7 +56,7 @@ export default {
item: Object,
params: Object,
},
}
};
</script>
<style>

View File

@ -3,9 +3,9 @@
<script>
export default {
data() {
return {}
return {};
},
methods: {},
components: {},
}
};
</script>

View File

@ -25,26 +25,26 @@
</template>
<script>
import { inject } from "vue"
import Breadcrumbs from "../Breadcrumbs.vue"
import Help from "../Help.vue"
import LeftMenu from "../LeftMenu.vue"
import Dialog from "../Dialog.vue"
import { APIClient } from "../../fetch/api-client.js"
import "vue-select/dist/vue-select.css"
import { storeToRefs } from "pinia"
import { inject } from "vue";
import Breadcrumbs from "../Breadcrumbs.vue";
import Help from "../Help.vue";
import LeftMenu from "../LeftMenu.vue";
import Dialog from "../Dialog.vue";
import { APIClient } from "../../fetch/api-client.js";
import "vue-select/dist/vue-select.css";
import { storeToRefs } from "pinia";
export default {
setup() {
const AVStore = inject("AVStore")
const AVStore = inject("AVStore");
const mainStore = inject("mainStore")
const mainStore = inject("mainStore");
const { loading, loaded, setError } = mainStore
const { loading, loaded, setError } = mainStore;
const PreservationStore = inject("PreservationStore")
const PreservationStore = inject("PreservationStore");
const { config } = storeToRefs(PreservationStore)
const { config } = storeToRefs(PreservationStore);
return {
AVStore,
@ -52,49 +52,49 @@ export default {
loaded,
config,
setError,
}
};
},
data() {
return {
initialized: false,
}
};
},
beforeCreate() {
this.loading()
this.loading();
const fetch_additional_config = () => {
let promises = []
const av_client = APIClient.authorised_values
let promises = [];
const av_client = APIClient.authorised_values;
promises.push(
av_client.values.get("NOT_LOAN").then(
values => {
this.AVStore.av_notforloan = values
this.AVStore.av_notforloan = values;
},
error => {}
)
)
return Promise.all(promises)
}
);
return Promise.all(promises);
};
const client = APIClient.preservation
const client = APIClient.preservation;
client.config
.get()
.then(config => {
this.config = config
this.config = config;
if (this.config.settings.enabled != 1) {
return this.setError(
this.$__(
'The preservation module is disabled, turn on <a href="/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=PreservationModule">PreservationModule</a> to use it'
),
false
)
);
}
return fetch_additional_config()
return fetch_additional_config();
})
.then(() => {
this.loaded()
this.initialized = true
})
this.loaded();
this.initialized = true;
});
},
components: {
@ -103,7 +103,7 @@ export default {
Help,
LeftMenu,
},
}
};
</script>
<style>

View File

@ -117,20 +117,20 @@
</template>
<script>
import { inject } from "vue"
import { APIClient } from "../../fetch/api-client.js"
import { storeToRefs } from "pinia"
import SettingsProcessings from "./SettingsProcessings.vue"
import { inject } from "vue";
import { APIClient } from "../../fetch/api-client.js";
import { storeToRefs } from "pinia";
import SettingsProcessings from "./SettingsProcessings.vue";
export default {
setup() {
const AVStore = inject("AVStore")
const { av_notforloan } = storeToRefs(AVStore)
const { get_lib_from_av } = AVStore
const AVStore = inject("AVStore");
const { av_notforloan } = storeToRefs(AVStore);
const { get_lib_from_av } = AVStore;
const { setMessage, setWarning } = inject("mainStore")
const PreservationStore = inject("PreservationStore")
const { config } = PreservationStore
const { setMessage, setWarning } = inject("mainStore");
const PreservationStore = inject("PreservationStore");
const { config } = PreservationStore;
return {
av_notforloan,
@ -138,25 +138,25 @@ export default {
setMessage,
setWarning,
config,
}
};
},
data() {
return {
initialized: true,
}
};
},
methods: {
checkForm(train) {
let errors = []
let errors = [];
errors.forEach(function (e) {
setWarning(e)
})
return !errors.length
setWarning(e);
});
return !errors.length;
},
onSubmit(e) {
e.preventDefault()
const client = APIClient.sysprefs
e.preventDefault();
const client = APIClient.sysprefs;
client.sysprefs
.update(
"PreservationNotForLoanWaitingListIn",
@ -170,13 +170,13 @@ export default {
)
.then(
success => {
this.setMessage(this.$__("Settings updated"), true)
this.setMessage(this.$__("Settings updated"), true);
},
error => {}
)
);
},
},
components: { SettingsProcessings },
name: "Settings",
}
};
</script>

View File

@ -45,29 +45,29 @@
</template>
<script>
import { inject } from "vue"
import { APIClient } from "../../fetch/api-client.js"
import { inject } from "vue";
import { APIClient } from "../../fetch/api-client.js";
export default {
setup() {
const { setConfirmationDialog, setMessage, setError } =
inject("mainStore")
return { setConfirmationDialog, setMessage, setError }
inject("mainStore");
return { setConfirmationDialog, setMessage, setError };
},
data() {
return {
processings: [],
}
};
},
beforeCreate() {
// FIXME Do we want that or a props passed from parent?
const client = APIClient.preservation
const client = APIClient.preservation;
client.processings.getAll().then(
processings => {
this.processings = processings
this.processings = processings;
},
error => {}
)
);
},
methods: {
deleteProcessing(processing) {
@ -81,7 +81,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.preservation
const client = APIClient.preservation;
client.processings.delete(processing.processing_id).then(
success => {
this.setMessage(
@ -89,13 +89,13 @@ export default {
processing.name
),
true
)
);
client.processings.getAll().then(
processings => {
this.processings = processings
this.processings = processings;
},
error => {}
)
);
},
error => {
// FIXME We need a better way to do that
@ -104,17 +104,17 @@ export default {
this.$__(
"This processing cannot be deleted, it is already in used."
)
)
);
}
}
)
);
}
)
);
},
},
props: {},
name: "SettingsProcessings",
}
};
</script>
<style scoped>

View File

@ -198,27 +198,27 @@
</template>
<script>
import { inject } from "vue"
import { APIClient } from "../../fetch/api-client.js"
import { storeToRefs } from "pinia"
import { inject } from "vue";
import { APIClient } from "../../fetch/api-client.js";
import { storeToRefs } from "pinia";
export default {
setup() {
const AVStore = inject("AVStore")
const {} = storeToRefs(AVStore)
const AVStore = inject("AVStore");
const {} = storeToRefs(AVStore);
const { setMessage, setWarning } = inject("mainStore")
const { setMessage, setWarning } = inject("mainStore");
const db_column_options = Object.keys(db_columns).map(function (c) {
return { label: "%s (%s)".format(db_columns[c], c), code: c }
})
return { label: "%s (%s)".format(db_columns[c], c), code: c };
});
return {
setMessage,
setWarning,
authorised_value_categories,
db_column_options,
notice_templates,
}
};
},
data() {
return {
@ -242,71 +242,71 @@ export default {
},
],
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (to.params.processing_id) {
vm.processing = vm.getProcessing(to.params.processing_id)
vm.processing = vm.getProcessing(to.params.processing_id);
} else {
vm.initialized = true
vm.initialized = true;
}
})
});
},
methods: {
async getProcessing(processing_id) {
const client = APIClient.preservation
const client = APIClient.preservation;
await client.processings.get(processing_id).then(
processing => {
this.processing = processing
this.initialized = true
this.processing = processing;
this.initialized = true;
},
error => {}
)
);
},
checkForm(processing) {
let errors = []
let errors = [];
let attributes = processing.attributes
let attributes = processing.attributes;
errors.forEach(function (e) {
setWarning(e)
})
setWarning(e);
});
return !errors.length
return !errors.length;
},
onSubmit(e) {
e.preventDefault()
e.preventDefault();
let processing = JSON.parse(JSON.stringify(this.processing)) // copy
let processing_id = processing.processing_id
delete processing.processing_id
let processing = JSON.parse(JSON.stringify(this.processing)); // copy
let processing_id = processing.processing_id;
delete processing.processing_id;
if (!this.checkForm(processing)) {
return false
return false;
}
processing.attributes = processing.attributes.map(
({ processing_id, ...keepAttrs }) => keepAttrs
)
);
const client = APIClient.preservation
const client = APIClient.preservation;
if (processing_id) {
client.processings.update(processing, processing_id).then(
success => {
this.setMessage(this.$__("Processing updated"))
this.$router.push({ name: "Settings" })
this.setMessage(this.$__("Processing updated"));
this.$router.push({ name: "Settings" });
},
error => {}
)
);
} else {
client.processings.create(processing).then(
success => {
this.setMessage(this.$__("Processing created"))
this.$router.push({ name: "Settings" })
this.setMessage(this.$__("Processing created"));
this.$router.push({ name: "Settings" });
},
error => {}
)
);
}
},
addAttribute() {
@ -314,15 +314,15 @@ export default {
name: "",
type: null,
option_source: null,
})
});
},
deleteAttribute(counter) {
this.processing.attributes.splice(counter, 1)
this.processing.attributes.splice(counter, 1);
},
},
components: {},
name: "SettingsProcessingsFormAdd",
}
};
</script>
<style>

View File

@ -87,26 +87,26 @@
</template>
<script>
import { inject } from "vue"
import { APIClient } from "../../fetch/api-client.js"
import Toolbar from "../Toolbar.vue"
import ToolbarButton from "../ToolbarButton.vue"
import { inject } from "vue";
import { APIClient } from "../../fetch/api-client.js";
import Toolbar from "../Toolbar.vue";
import ToolbarButton from "../ToolbarButton.vue";
export default {
setup() {
const { setConfirmationDialog, setMessage } = inject("mainStore")
const { setConfirmationDialog, setMessage } = inject("mainStore");
return {
notice_templates,
setConfirmationDialog,
setMessage,
}
};
},
computed: {
notice_template() {
return this.notice_templates.find(
n => n.id == this.processing.letter_code
)
);
},
},
data() {
@ -118,26 +118,26 @@ export default {
attributes: [],
},
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getProcessing(to.params.processing_id)
})
vm.getProcessing(to.params.processing_id);
});
},
beforeRouteUpdate(to, from) {
this.processing = this.getProcessing(to.params.processing_id)
this.processing = this.getProcessing(to.params.processing_id);
},
methods: {
async getProcessing(processing_id) {
const client = APIClient.preservation
const client = APIClient.preservation;
await client.processings.get(processing_id).then(
processing => {
this.processing = processing
this.initialized = true
this.processing = processing;
this.initialized = true;
},
error => {}
)
);
},
doDelete: function () {
this.setConfirmationDialog(
@ -150,7 +150,7 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.preservation
const client = APIClient.preservation;
client.processings
.delete(this.processing.processing_id)
.then(
@ -160,17 +160,17 @@ export default {
this.processing.name
),
true
)
this.$router.push({ name: "Settings" })
);
this.$router.push({ name: "Settings" });
},
error => {}
)
);
}
)
);
},
},
components: { Toolbar, ToolbarButton },
name: "ProcessingsShow",
}
};
</script>
<style scoped></style>

View File

@ -95,21 +95,21 @@
</template>
<script>
import { inject } from "vue"
import { storeToRefs } from "pinia"
import { APIClient } from "../../fetch/api-client.js"
import { inject } from "vue";
import { storeToRefs } from "pinia";
import { APIClient } from "../../fetch/api-client.js";
export default {
setup() {
const AVStore = inject("AVStore")
const { av_notforloan } = storeToRefs(AVStore)
const AVStore = inject("AVStore");
const { av_notforloan } = storeToRefs(AVStore);
const { setMessage, setWarning } = inject("mainStore")
const { setMessage, setWarning } = inject("mainStore");
const PreservationStore = inject("PreservationStore")
const { config } = PreservationStore
const PreservationStore = inject("PreservationStore");
const { config } = PreservationStore;
return { av_notforloan, setMessage, setWarning, config }
return { av_notforloan, setMessage, setWarning, config };
},
data() {
return {
@ -127,76 +127,76 @@ export default {
},
processings: [],
initialized: false,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
if (to.params.train_id) {
vm.train = vm.getTrain(to.params.train_id)
vm.train = vm.getTrain(to.params.train_id);
} else {
vm.initialized = true
vm.initialized = true;
}
})
});
},
beforeCreate() {
const client = APIClient.preservation
const client = APIClient.preservation;
client.processings.getAll().then(
processings => {
this.processings = processings
this.processings = processings;
},
error => {}
)
);
},
methods: {
async getTrain(train_id) {
const client = APIClient.preservation
const client = APIClient.preservation;
client.trains.get(train_id).then(train => {
this.train = train
this.initialized = true
})
this.train = train;
this.initialized = true;
});
},
checkForm(train) {
let errors = []
let errors = [];
errors.forEach(function (e) {
setWarning(e)
})
return !errors.length
setWarning(e);
});
return !errors.length;
},
onSubmit(e) {
e.preventDefault()
e.preventDefault();
let train = JSON.parse(JSON.stringify(this.train)) // copy
let train_id = train.train_id
let train = JSON.parse(JSON.stringify(this.train)); // copy
let train_id = train.train_id;
if (!this.checkForm(train)) {
return false
return false;
}
delete train.train_id
delete train.default_processing
delete train.items
delete train.train_id;
delete train.default_processing;
delete train.items;
const client = APIClient.preservation
const client = APIClient.preservation;
if (train_id) {
client.trains.update(train, train_id).then(
success => {
this.setMessage(this.$__("Train updated"))
this.$router.push({ name: "TrainsList" })
this.setMessage(this.$__("Train updated"));
this.$router.push({ name: "TrainsList" });
},
error => {}
)
);
} else {
client.trains.create(train).then(
success => {
this.setMessage(this.$__("Train created"))
this.$router.push({ name: "TrainsList" })
this.setMessage(this.$__("Train created"));
this.$router.push({ name: "TrainsList" });
},
error => {}
)
);
}
},
},
components: {},
name: "TrainsFormAdd",
}
};
</script>

View File

@ -148,19 +148,19 @@
</template>
<script>
import { inject } from "vue"
import { APIClient } from "../../fetch/api-client"
import { inject } from "vue";
import { APIClient } from "../../fetch/api-client";
export default {
setup() {
const { setMessage, setWarning, loading, loaded } = inject("mainStore")
const { setMessage, setWarning, loading, loaded } = inject("mainStore");
return {
setMessage,
setWarning,
loading,
loaded,
api_mappings,
}
};
},
data() {
return {
@ -178,13 +178,13 @@ export default {
av_options: {},
default_values: {},
attributes: [],
}
};
},
beforeCreate() {
const client = APIClient.preservation
const client = APIClient.preservation;
client.processings
.getAll()
.then(processings => (this.processings = processings))
.then(processings => (this.processings = processings));
},
beforeRouteEnter(to, from, next) {
next(vm => {
@ -202,37 +202,37 @@ export default {
.refreshAttributes()
.then(() => (vm.initialized = true))
)
)
);
} else {
vm.train = vm
.getTrain(to.params.train_id)
.then(() => (vm.initialized = true))
.then(() => (vm.initialized = true));
}
})
});
},
methods: {
async getTrain(train_id) {
const client = APIClient.preservation
const client = APIClient.preservation;
await client.trains.get(train_id).then(
train => {
this.train = train
this.train = train;
},
error => {}
)
);
},
async getTrainItem(train_id, train_item_id) {
const client = APIClient.preservation
const client = APIClient.preservation;
await client.train_items.get(train_id, train_item_id).then(
train_item => {
this.train_item = train_item
this.item = train_item.catalogue_item
this.train_item = train_item;
this.item = train_item.catalogue_item;
},
error => {}
)
);
},
async getItemFromWaitingList(e) {
e.preventDefault()
const client = APIClient.preservation
e.preventDefault();
const client = APIClient.preservation;
client.waiting_list_items.get_from_barcode(this.barcode).then(
item => {
if (!item) {
@ -240,48 +240,48 @@ export default {
this.$__(
"Cannot find item with this barcode. It must be in the waiting list."
)
)
return
);
return;
}
this.item = item
this.item = item;
this.train_item = {
item_id: item.item_id,
processing_id: this.train.default_processing_id,
}
this.refreshAttributes(1)
};
this.refreshAttributes(1);
},
error => {}
)
);
},
columnApiMapping(db_column) {
let table_col = db_column.split(".")
let table = table_col[0]
let col = table_col[1]
let api_attribute = this.api_mappings[table][col] || col
let table_col = db_column.split(".");
let table = table_col[0];
let col = table_col[1];
let api_attribute = this.api_mappings[table][col] || col;
return table == "biblio" || table == "biblioitems"
? this.item.biblio[api_attribute]
: this.item[api_attribute]
: this.item[api_attribute];
},
updateDefaultValues() {
this.processing.attributes
.filter(attribute => attribute.type == "db_column")
.forEach(attribute => {
this.default_values[attribute.processing_attribute_id] =
this.columnApiMapping(attribute.option_source)
})
this.columnApiMapping(attribute.option_source);
});
},
async refreshAttributes(apply_default_value) {
this.loading()
this.loading();
const client = APIClient.preservation
const client = APIClient.preservation;
await client.processings.get(this.train_item.processing_id).then(
processing => (this.processing = processing),
error => {}
)
this.updateDefaultValues()
this.attributes = []
);
this.updateDefaultValues();
this.attributes = [];
this.processing.attributes.forEach(attribute => {
let values = []
let values = [];
if (!apply_default_value) {
this.train_item.attributes
.filter(
@ -289,13 +289,13 @@ export default {
a.processing_attribute_id ==
attribute.processing_attribute_id
)
.forEach(a => values.push(a.value))
.forEach(a => values.push(a.value));
} else if (attribute.type == "db_column") {
values.push(
this.default_values[attribute.processing_attribute_id]
)
);
} else {
values.push("")
values.push("");
}
values.forEach(value =>
this.attributes.push({
@ -306,12 +306,12 @@ export default {
option_source: attribute.option_source,
value,
})
)
})
const client_av = APIClient.authorised_values
);
});
const client_av = APIClient.authorised_values;
let av_cat_array = this.processing.attributes
.filter(attribute => attribute.type == "authorised_value")
.map(attribute => attribute.option_source)
.map(attribute => attribute.option_source);
client_av.values
.getCategoriesWithValues([
@ -321,31 +321,31 @@ export default {
av_cat_array.forEach(av_cat => {
let av_match = av_categories.find(
element => element.category_name == av_cat
)
);
this.av_options[av_cat] = av_match
? av_match.authorised_values
: []
})
: [];
});
})
.then(() => this.loaded())
.then(() => this.loaded());
},
addAttribute(processing_attribute_id) {
let last_index = this.attributes.findLastIndex(
attribute =>
attribute.processing_attribute_id == processing_attribute_id
)
);
let new_attribute = (({ value, ...keepAttrs }) => keepAttrs)(
this.attributes[last_index]
)
this.attributes.splice(last_index + 1, 0, new_attribute)
);
this.attributes.splice(last_index + 1, 0, new_attribute);
},
removeAttribute(counter) {
this.attributes.splice(counter, 1)
this.attributes.splice(counter, 1);
},
onSubmit(e) {
e.preventDefault()
e.preventDefault();
let train_item_id = this.train_item.train_item_id
let train_item_id = this.train_item.train_item_id;
let train_item = {
item_id: this.train_item.item_id,
processing_id: this.train_item.processing_id,
@ -353,37 +353,37 @@ export default {
processing_attribute_id: a.processing_attribute_id,
value: a.value,
})),
}
};
const client = APIClient.preservation
const client = APIClient.preservation;
if (train_item_id) {
client.train_items
.update(train_item, this.train.train_id, train_item_id)
.then(
success => {
this.setMessage(this.$__("Item updated"))
this.setMessage(this.$__("Item updated"));
this.$router.push({
name: "TrainsShow",
params: { train_id: this.train.train_id },
})
});
},
error => {}
)
);
} else {
client.train_items.create(train_item, this.train.train_id).then(
success => {
this.setMessage(this.$__("Item added to train"))
this.setMessage(this.$__("Item added to train"));
this.$router.push({
name: "TrainsShow",
params: { train_id: this.train.train_id },
})
});
},
error => {}
)
);
}
},
},
components: {},
name: "TrainsFormAdd",
}
};
</script>

View File

@ -105,19 +105,19 @@
</template>
<script>
import { inject } from "vue"
import { APIClient } from "../../fetch/api-client"
import { inject } from "vue";
import { APIClient } from "../../fetch/api-client";
export default {
setup() {
const { setMessage, setWarning, loading, loaded } = inject("mainStore")
const { setMessage, setWarning, loading, loaded } = inject("mainStore");
return {
setMessage,
setWarning,
loading,
loaded,
api_mappings,
}
};
},
data() {
return {
@ -134,13 +134,13 @@ export default {
initialized: false,
av_options: {},
attributes: [],
}
};
},
beforeCreate() {
const client = APIClient.preservation
const client = APIClient.preservation;
client.processings
.getAll()
.then(processings => (this.processings = processings))
.then(processings => (this.processings = processings));
},
beforeRouteEnter(to, from, next) {
next(vm => {
@ -154,48 +154,48 @@ export default {
.refreshAttributes()
.then(() => (vm.initialized = true))
)
)
})
);
});
},
methods: {
async getTrain(train_id) {
const client = APIClient.preservation
const client = APIClient.preservation;
await client.trains.get(train_id).then(
train => {
this.train = train
this.processing_id = train.default_processing_id
this.train = train;
this.processing_id = train.default_processing_id;
},
error => {}
)
);
},
async getItems(item_ids) {
const client = APIClient.item
let q = { "me.item_id": item_ids }
const client = APIClient.item;
let q = { "me.item_id": item_ids };
await client.items.getAll(q, {}, { "x-koha-embed": "biblio" }).then(
items => {
this.items = items
this.items = items;
},
error => {}
)
);
},
columnApiMapping(item, db_column) {
let table_col = db_column.split(".")
let table = table_col[0]
let col = table_col[1]
let api_attribute = this.api_mappings[table][col] || col
let table_col = db_column.split(".");
let table = table_col[0];
let col = table_col[1];
let api_attribute = this.api_mappings[table][col] || col;
return table == "biblio" || table == "biblioitems"
? item.biblio[api_attribute]
: item[api_attribute]
: item[api_attribute];
},
async refreshAttributes() {
this.loading()
this.loading();
const client = APIClient.preservation
const client = APIClient.preservation;
await client.processings.get(this.processing_id).then(
processing => (this.processing = processing),
error => {}
)
this.attributes = []
);
this.attributes = [];
this.processing.attributes.forEach(attribute => {
this.attributes.push({
processing_attribute_id: attribute.processing_attribute_id,
@ -203,12 +203,12 @@ export default {
type: attribute.type,
option_source: attribute.option_source,
value: "",
})
})
const client_av = APIClient.authorised_values
});
});
const client_av = APIClient.authorised_values;
let av_cat_array = this.processing.attributes
.filter(attribute => attribute.type == "authorised_value")
.map(attribute => attribute.option_source)
.map(attribute => attribute.option_source);
client_av.values
.getCategoriesWithValues([
@ -218,27 +218,27 @@ export default {
av_cat_array.forEach(av_cat => {
let av_match = av_categories.find(
element => element.category_name == av_cat
)
this.av_options[av_cat] = av_match.authorised_values
})
);
this.av_options[av_cat] = av_match.authorised_values;
});
})
.then(() => this.loaded())
.then(() => this.loaded());
},
addAttribute(processing_attribute_id) {
let last_index = this.attributes.findLastIndex(
attribute =>
attribute.processing_attribute_id == processing_attribute_id
)
);
let new_attribute = (({ value, ...keepAttrs }) => keepAttrs)(
this.attributes[last_index]
)
this.attributes.splice(last_index + 1, 0, new_attribute)
);
this.attributes.splice(last_index + 1, 0, new_attribute);
},
removeAttribute(counter) {
this.attributes.splice(counter, 1)
this.attributes.splice(counter, 1);
},
onSubmit(e) {
e.preventDefault()
e.preventDefault();
let train_items = this.items.map(item => {
return {
@ -248,16 +248,16 @@ export default {
let value =
a.type == "db_column"
? this.columnApiMapping(item, a.option_source)
: a.value
: a.value;
return {
processing_attribute_id: a.processing_attribute_id,
value,
}
};
}),
}
})
};
});
const client = APIClient.preservation
const client = APIClient.preservation;
client.train_items.createAll(train_items, this.train.train_id).then(
result => {
if (result.length) {
@ -265,22 +265,22 @@ export default {
this.$__(
"%s items have been added to train %s."
).format(result.length, this.train.train_id)
)
);
this.$router.push({
name: "TrainsShow",
params: { train_id: this.train.train_id },
})
});
} else {
this.setMessage(
this.$__("No items have been added to the train.")
)
);
}
},
error => {}
)
);
},
},
components: {},
name: "TrainsFormAddItems",
}
};
</script>

View File

@ -59,22 +59,22 @@
</template>
<script>
import flatPickr from "vue-flatpickr-component"
import Toolbar from "../Toolbar.vue"
import ToolbarButton from "../ToolbarButton.vue"
import { inject, ref, reactive } from "vue"
import { APIClient } from "../../fetch/api-client"
import { build_url } from "../../composables/datatables"
import KohaTable from "../KohaTable.vue"
import flatPickr from "vue-flatpickr-component";
import Toolbar from "../Toolbar.vue";
import ToolbarButton from "../ToolbarButton.vue";
import { inject, ref, reactive } from "vue";
import { APIClient } from "../../fetch/api-client";
import { build_url } from "../../composables/datatables";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const AVStore = inject("AVStore")
const { get_lib_from_av, map_av_dt_filter } = AVStore
const AVStore = inject("AVStore");
const { get_lib_from_av, map_av_dt_filter } = AVStore;
const { setConfirmationDialog, setMessage, setWarning } =
inject("mainStore")
const table = ref()
const filters = reactive({ status: "" })
inject("mainStore");
const table = ref();
const filters = reactive({ status: "" });
return {
get_lib_from_av,
map_av_dt_filter,
@ -83,10 +83,10 @@ export default {
setWarning,
table,
filters,
}
};
},
data: function () {
this.filters.status = this.$route.query.status || ""
this.filters.status = this.$route.query.status || "";
return {
fp_config: flatpickr_defaults,
count_trains: 0,
@ -117,37 +117,37 @@ export default {
],
},
},
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getCountTrains()
})
vm.getCountTrains();
});
},
computed: {},
methods: {
async getCountTrains() {
const client = APIClient.preservation
const client = APIClient.preservation;
client.trains.count().then(
count => {
this.count_trains = count
this.initialized = true
this.count_trains = count;
this.initialized = true;
},
error => {}
)
);
},
doShow: function (train, dt, event) {
event.preventDefault()
event.preventDefault();
this.$router.push({
name: "TrainsShow",
params: { train_id: train.train_id },
})
});
},
doEdit: function (train, dt, event) {
this.$router.push({
name: "TrainsFormEdit",
params: { train_id: train.train_id },
})
});
},
doDelete: function (train, dt, event) {
this.setConfirmationDialog(
@ -160,70 +160,70 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.preservation
const client = APIClient.preservation;
client.trains.delete(train.train_id).then(
success => {
this.setMessage(
this.$__("Train %s deleted").format(train.name),
true
)
dt.draw()
);
dt.draw();
},
error => {}
)
);
}
)
);
},
doAddItems: function (train, dt, event) {
if (train.closed_on != null) {
this.setWarning(this.$__("Cannot add items to a closed train"))
this.setWarning(this.$__("Cannot add items to a closed train"));
} else {
this.$router.push({
name: "TrainsFormAddItem",
params: { train_id: train.train_id },
})
});
}
},
table_url() {
let url = "/api/v1/preservation/trains"
let q
let url = "/api/v1/preservation/trains";
let q;
if (this.filters.status == "closed") {
q = {
"me.closed_on": { "!=": null },
"me.sent_on": null,
"me.received_on": null,
}
};
} else if (this.filters.status == "sent") {
q = {
"me.closed_on": { "!=": null },
"me.sent_on": { "!=": null },
"me.received_on": null,
}
};
} else if (this.filters.status == "received") {
q = {
"me.closed_on": { "!=": null },
"me.sent_on": { "!=": null },
"me.received_on": { "!=": null },
}
};
}
if (q) {
url += "?" + new URLSearchParams({ q: JSON.stringify(q) })
url += "?" + new URLSearchParams({ q: JSON.stringify(q) });
}
return url
return url;
},
filter_table: async function () {
let new_route = build_url(
"/cgi-bin/koha/preservation/trains",
this.filters
)
this.$router.push(new_route)
);
this.$router.push(new_route);
if (this.$refs.table) {
this.$refs.table.redraw(this.table_url())
this.$refs.table.redraw(this.table_url());
}
},
getTableColumns: function () {
let escape_str = this.escape_str
let escape_str = this.escape_str;
return [
{
title: __("Name"),
@ -231,7 +231,7 @@ export default {
searchable: true,
orderable: true,
render: function (data, type, row, meta) {
return `<a href="/cgi-bin/koha/preservation/trains/${row.train_id}" class="show">${row.name} (#${row.train_id})</a>`
return `<a href="/cgi-bin/koha/preservation/trains/${row.train_id}" class="show">${row.name} (#${row.train_id})</a>`;
},
},
{
@ -240,7 +240,7 @@ export default {
searchable: true,
orderable: true,
render: function (data, type, row, meta) {
return $date(row.created_on)
return $date(row.created_on);
},
},
{
@ -249,7 +249,7 @@ export default {
searchable: true,
orderable: true,
render: function (data, type, row, meta) {
return $date(row.closed_on)
return $date(row.closed_on);
},
},
{
@ -258,7 +258,7 @@ export default {
searchable: true,
orderable: true,
render: function (data, type, row, meta) {
return $date(row.sent_on)
return $date(row.sent_on);
},
},
{
@ -267,16 +267,16 @@ export default {
searchable: true,
orderable: true,
render: function (data, type, row, meta) {
return $date(row.received_on)
return $date(row.received_on);
},
},
]
];
},
},
components: { flatPickr, Toolbar, ToolbarButton, KohaTable },
name: "trainsList",
emits: ["select-train", "close"],
}
};
</script>
<style scoped>

View File

@ -281,24 +281,24 @@
</template>
<script>
import { inject, createVNode, render } from "vue"
import { APIClient } from "../../fetch/api-client"
import { useDataTable } from "../../composables/datatables"
import Toolbar from "../Toolbar.vue"
import ToolbarButton from "../ToolbarButton.vue"
import { inject, createVNode, render } from "vue";
import { APIClient } from "../../fetch/api-client";
import { useDataTable } from "../../composables/datatables";
import Toolbar from "../Toolbar.vue";
import ToolbarButton from "../ToolbarButton.vue";
export default {
setup() {
const format_date = $date
const format_date = $date;
const AVStore = inject("AVStore")
const { get_lib_from_av } = AVStore
const AVStore = inject("AVStore");
const { get_lib_from_av } = AVStore;
const { setConfirmationDialog, setMessage, setWarning } =
inject("mainStore")
inject("mainStore");
const table_id = "item_list"
useDataTable(table_id)
const table_id = "item_list";
useDataTable(table_id);
return {
format_date,
@ -307,7 +307,7 @@ export default {
setConfirmationDialog,
setMessage,
setWarning,
}
};
},
data() {
return {
@ -327,29 +327,29 @@ export default {
train_item_id_to_copy: null,
selected_items: [],
av_options: {},
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getTrain(to.params.train_id).then(() => vm.build_datatable())
vm.getTrainList()
})
vm.getTrain(to.params.train_id).then(() => vm.build_datatable());
vm.getTrainList();
});
},
methods: {
async getTrain(train_id) {
const client = APIClient.preservation
const client = APIClient.preservation;
await client.trains.get(train_id).then(
train => {
this.train = train
this.train = train;
let display_table = this.train.items.every(
item =>
item.processing_id ==
this.train.default_processing_id
)
);
if (display_table) {
this.item_table.data = []
this.item_table.data = [];
this.train.items.forEach(item => {
let item_row = {}
let item_row = {};
this.train.default_processing.attributes.forEach(
attribute => {
item_row[
@ -360,20 +360,20 @@ export default {
a.processing_attribute_id ==
attribute.processing_attribute_id
)
.map(a => a._strings.value.str)
.map(a => a._strings.value.str);
}
)
item_row.item = item
this.item_table.data.push(item_row)
})
this.item_table.columns = []
);
item_row.item = item;
this.item_table.data.push(item_row);
});
this.item_table.columns = [];
this.item_table.columns.push(
{
name: "checkboxes",
className: "checkboxes",
width: "5%",
render: (data, type, row) => {
return ""
return "";
},
},
{
@ -381,17 +381,17 @@ export default {
title: this.$__("ID"),
data: "item.user_train_item_id",
}
)
);
train.default_processing.attributes.forEach(a =>
this.item_table.columns.push({
name: a.name,
title: a.name,
data: a.processing_attribute_id,
render: (data, type, row) => {
return data.join("<br/>")
return data.join("<br/>");
},
})
)
);
this.item_table.columns.push({
name: "actions",
className: "actions noExport",
@ -399,23 +399,23 @@ export default {
searchable: false,
orderable: false,
render: (data, type, row) => {
return ""
return "";
},
})
});
}
this.initialized = true
this.item_table.display = display_table
this.initialized = true;
this.item_table.display = display_table;
},
error => {}
)
);
},
getTrainList: function () {
const client = APIClient.preservation
let q = { "me.closed_on": null }
const client = APIClient.preservation;
let q = { "me.closed_on": null };
client.trains.getAll(q).then(
trains => (this.train_list = trains),
error => {}
)
);
},
deleteTrain: function (train) {
this.setConfirmationDialog(
@ -428,43 +428,43 @@ export default {
cancel_label: this.$__("No, do not delete"),
},
() => {
const client = APIClient.preservation
const client = APIClient.preservation;
client.trains.delete(train.train_id).then(
success => {
this.setMessage(
this.$__("Train %s deleted").format(train.name),
true
)
this.$router.push({ name: "TrainsList" })
);
this.$router.push({ name: "TrainsList" });
},
error => {}
)
);
}
)
);
},
async updateTrainDate(attribute) {
let train = JSON.parse(JSON.stringify(this.train))
let train_id = train.train_id
delete train.train_id
delete train.items
delete train.default_processing
train[attribute] = new Date()
const client = APIClient.preservation
let train = JSON.parse(JSON.stringify(this.train));
let train_id = train.train_id;
delete train.train_id;
delete train.items;
delete train.default_processing;
train[attribute] = new Date();
const client = APIClient.preservation;
if (train_id) {
return client.trains
.update(train, train_id)
.then(() => this.getTrain(this.train.train_id))
.then(() => this.getTrain(this.train.train_id));
} else {
return client.trains
.create(train)
.then(() => this.getTrain(this.train.train_id))
.then(() => this.getTrain(this.train.train_id));
}
},
closeTrain() {
this.updateTrainDate("closed_on")
this.updateTrainDate("closed_on");
},
sendTrain() {
this.updateTrainDate("sent_on")
this.updateTrainDate("sent_on");
},
receiveTrain() {
this.updateTrainDate("received_on").then(
@ -472,17 +472,17 @@ export default {
// Rebuild the table to show the "copy" button
$("#" + this.table_id)
.DataTable()
.destroy()
this.build_datatable()
.destroy();
this.build_datatable();
},
error => {}
)
);
},
editItem(train_item_id) {
this.$router.push({
name: "TrainsFormEditItem",
params: { train_id: this.train.train_id, train_item_id },
})
});
},
removeItem(train_item_id) {
this.setConfirmationDialog(
@ -494,38 +494,38 @@ export default {
cancel_label: this.$__("No, do not remove"),
},
() => {
const client = APIClient.preservation
const client = APIClient.preservation;
client.train_items
.delete(this.train.train_id, train_item_id)
.then(
success => {
this.setMessage(this.$__("Item removed"), true)
this.setMessage(this.$__("Item removed"), true);
this.getTrain(this.train.train_id).then(() => {
$("#" + this.table_id)
.DataTable()
.destroy()
this.build_datatable()
})
.destroy();
this.build_datatable();
});
},
error => {}
)
);
}
)
);
},
printSlip(train_item_id) {
window.open(
"/cgi-bin/koha/preservation/print_slip.pl?train_item_id=" +
train_item_id,
"_blank"
)
);
},
selectTrainForCopy(train_item_id) {
$("#copy_item_to_train").modal("show")
this.train_item_id_to_copy = train_item_id
$("#copy_item_to_train").modal("show");
this.train_item_id_to_copy = train_item_id;
},
copyItem(event) {
event.preventDefault()
const client = APIClient.preservation
event.preventDefault();
const client = APIClient.preservation;
client.train_items
.copy(
this.train_id_selected_for_copy,
@ -534,24 +534,24 @@ export default {
)
.then(
success => {
this.setMessage(this.$__("Item copied successfully."))
$("#copy_item_to_train").modal("hide")
this.setMessage(this.$__("Item copied successfully."));
$("#copy_item_to_train").modal("hide");
},
error => {
this.setWarning(
this.$__(
"Item cannot be copied to a train, it is already in a non-received train."
)
)
);
}
)
);
},
clearAll() {
this.selected_items = []
this.selected_items = [];
if (this.item_table.display) {
$("#" + this.table_id)
.find("input[name='user_train_item_id'][type='checkbox']")
.prop("checked", false)
.prop("checked", false);
}
},
selectAll() {
@ -561,13 +561,13 @@ export default {
"input[name='user_train_item_id'][type='checkbox']:not(:disabled)"
)
.each((i, input) => {
this.selected_items.push($(input).val())
$(input).prop("checked", true)
})
this.selected_items.push($(input).val());
$(input).prop("checked", true);
});
} else {
this.selected_items = this.train.items
.filter(i => i.processing.letter_code)
.map(item => item.train_item_id)
.map(item => item.train_item_id);
}
},
printSelected() {
@ -577,26 +577,26 @@ export default {
.map(id => "train_item_id=" + id)
.join("&")
)
)
);
},
updateSelectedItems(checked, train_item_id) {
if (checked) {
this.selected_items.push(train_item_id)
this.selected_items.push(train_item_id);
} else {
this.selected_items = this.selected_items.filter(
id => id != train_item_id
)
);
}
},
build_datatable: function () {
let table_id = this.table_id
let item_table = this.item_table
let removeItem = this.removeItem
let editItem = this.editItem
let printSlip = this.printSlip
let selectTrainForCopy = this.selectTrainForCopy
let train = this.train
let updateSelectedItems = this.updateSelectedItems
let table_id = this.table_id;
let item_table = this.item_table;
let removeItem = this.removeItem;
let editItem = this.editItem;
let printSlip = this.printSlip;
let selectTrainForCopy = this.selectTrainForCopy;
let train = this.train;
let updateSelectedItems = this.updateSelectedItems;
let table = KohaTable(table_id, {
data: item_table.data,
@ -604,11 +604,11 @@ export default {
autoWidth: false,
columns: item_table.columns,
drawCallback: function (settings) {
var api = new $.fn.dataTable.Api(settings)
var api = new $.fn.dataTable.Api(settings);
$.each($(this).find("td.checkboxes"), function (index, e) {
let tr = $(this).parent()
let train_item = api.row(tr).data().item
let train_item_id = train_item.train_item_id
let tr = $(this).parent();
let train_item = api.row(tr).data().item;
let train_item_id = train_item.train_item_id;
let checkbox = createVNode("input", {
...(!train_item.processing.letter_code && {
@ -624,16 +624,16 @@ export default {
updateSelectedItems(
e.target.checked,
train_item_id
)
);
},
})
});
render(checkbox, e)
})
render(checkbox, e);
});
$.each($(this).find("td.actions"), function (index, e) {
let tr = $(this).parent()
let train_item = api.row(tr).data().item
let train_item_id = train_item.train_item_id
let tr = $(this).parent();
let train_item = api.row(tr).data().item;
let train_item_id = train_item.train_item_id;
let editButton = createVNode(
"a",
@ -641,7 +641,7 @@ export default {
class: "btn btn-default btn-xs",
role: "button",
onClick: () => {
editItem(train_item_id)
editItem(train_item_id);
},
},
[
@ -652,7 +652,7 @@ export default {
" ",
__("Edit"),
]
)
);
let removeButton = createVNode(
"a",
@ -660,7 +660,7 @@ export default {
class: "btn btn-default btn-xs",
role: "button",
onClick: () => {
removeItem(train_item_id)
removeItem(train_item_id);
},
},
[
@ -671,11 +671,11 @@ export default {
" ",
__("Remove"),
]
)
let buttons = [editButton, " ", removeButton]
);
let buttons = [editButton, " ", removeButton];
if (train.received_on !== null) {
buttons.push(" ")
buttons.push(" ");
buttons.push(
createVNode(
"a",
@ -683,7 +683,7 @@ export default {
class: "btn btn-default btn-xs",
role: "button",
onClick: () => {
selectTrainForCopy(train_item_id)
selectTrainForCopy(train_item_id);
},
},
[
@ -695,7 +695,7 @@ export default {
__("Copy"),
]
)
)
);
}
if (train_item.processing.letter_code) {
@ -705,7 +705,7 @@ export default {
class: "btn btn-default btn-xs",
role: "button",
onClick: () => {
printSlip(train_item_id)
printSlip(train_item_id);
},
},
[
@ -715,21 +715,21 @@ export default {
}),
__("Print slip"),
]
)
buttons.push(" ")
buttons.push(printButton)
);
buttons.push(" ");
buttons.push(printButton);
}
let n = createVNode("span", {}, buttons)
render(n, e)
})
let n = createVNode("span", {}, buttons);
render(n, e);
});
},
})
});
},
},
components: { Toolbar, ToolbarButton },
name: "TrainsShow",
}
};
</script>
<style scoped>
.action_links a {

View File

@ -176,19 +176,19 @@
</template>
<script>
import flatPickr from "vue-flatpickr-component"
import Toolbar from "../Toolbar.vue"
import { inject, ref } from "vue"
import { storeToRefs } from "pinia"
import { APIClient } from "../../fetch/api-client"
import KohaTable from "../KohaTable.vue"
import flatPickr from "vue-flatpickr-component";
import Toolbar from "../Toolbar.vue";
import { inject, ref } from "vue";
import { storeToRefs } from "pinia";
import { APIClient } from "../../fetch/api-client";
import KohaTable from "../KohaTable.vue";
export default {
setup() {
const table = ref()
const table = ref();
const PreservationStore = inject("PreservationStore")
const { config } = PreservationStore
const PreservationStore = inject("PreservationStore");
const { config } = PreservationStore;
const {
setMessage,
@ -196,7 +196,7 @@ export default {
setConfirmationDialog,
loading,
loaded,
} = inject("mainStore")
} = inject("mainStore");
return {
table,
@ -206,7 +206,7 @@ export default {
setConfirmationDialog,
loading,
loaded,
}
};
},
data: function () {
return {
@ -227,49 +227,49 @@ export default {
last_items: [],
train_list: [],
train_id_selected_for_add: null,
}
};
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.getCountWaitingListItems()
vm.getTrainList()
})
vm.getCountWaitingListItems();
vm.getTrainList();
});
},
methods: {
async getCountWaitingListItems() {
const client = APIClient.preservation
const client = APIClient.preservation;
client.waiting_list_items.count().then(count => {
this.count_waiting_list_items = count
this.initialized = true
})
this.count_waiting_list_items = count;
this.initialized = true;
});
},
getTrainList: function () {
const client = APIClient.preservation
const client = APIClient.preservation;
client.trains.getAll().then(
trains => (this.train_list = trains),
error => {}
)
);
},
addItemsToTrain: function (e) {
e.preventDefault()
$("#add_to_train").modal("hide")
let item_ids = this.last_items.map(i => i.item_id)
e.preventDefault();
$("#add_to_train").modal("hide");
let item_ids = this.last_items.map(i => i.item_id);
this.$router.push({
name: "TrainsFormAddItems",
params: {
train_id: this.train_id_selected_for_add,
item_ids: item_ids.join(","),
},
})
});
},
addItemsToWaitingList: function (e) {
e.preventDefault()
$("#add_to_waiting_list").modal("hide")
let items = []
e.preventDefault();
$("#add_to_waiting_list").modal("hide");
let items = [];
this.barcode_list
.split("\n")
.forEach(barcode => items.push({ barcode }))
const client = APIClient.preservation
.forEach(barcode => items.push({ barcode }));
const client = APIClient.preservation;
client.waiting_list_items.createAll(items).then(
result => {
if (result.length) {
@ -282,36 +282,36 @@ export default {
items.length - result.length
),
true
)
);
} else {
this.setMessage(
this.$__("%s new items added.").format(
result.length
),
true
)
);
}
this.last_items = result
this.last_items = result;
if (this.$refs.table) {
this.$refs.table.redraw(
"/api/v1/preservation/waiting-list/items"
)
);
} else {
this.getCountWaitingListItems()
this.getCountWaitingListItems();
}
} else {
this.setWarning(this.$__("No items added"))
this.setWarning(this.$__("No items added"));
}
},
error => {}
)
this.barcode_list = ""
);
this.barcode_list = "";
},
doShow: function (biblio, dt, event) {
event.preventDefault()
event.preventDefault();
location.href =
"/cgi-bin/koha/catalogue/detail.pl?biblionumber=" +
biblio.biblio_id
biblio.biblio_id;
},
doRemoveItem: function (item, dt, event) {
this.setConfirmationDialog(
@ -324,22 +324,22 @@ export default {
cancel_label: this.$__("No, do not remove"),
},
() => {
const client = APIClient.preservation
const client = APIClient.preservation;
client.waiting_list_items.delete(item.item_id).then(
success => {
this.setMessage(
this.$__("Item removed from the waiting list"),
true
)
dt.draw()
);
dt.draw();
},
error => {}
)
);
}
)
);
},
getTableColumns: function () {
let escape_str = this.escape_str
let escape_str = this.escape_str;
return [
{
data: "biblio.title",
@ -347,7 +347,7 @@ export default {
searchable: true,
orderable: true,
render: function (data, type, row, meta) {
return `<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=${row.biblio.biblio_id}">${row.biblio.title}</a>`
return `<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=${row.biblio.biblio_id}">${row.biblio.title}</a>`;
},
},
{
@ -368,12 +368,12 @@ export default {
searchable: true,
orderable: true,
},
]
];
},
},
components: { flatPickr, KohaTable, Toolbar },
name: "WaitingList",
}
};
</script>
<style scoped>

View File

@ -7,5 +7,5 @@
<script>
export default {
name: "Toolbar",
}
};
</script>

View File

@ -19,5 +19,5 @@ export default {
},
},
name: "Toolbar",
}
};
</script>