Skip to content
Snippets Groups Projects
Commit 3de41d15 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: move datamodel config to a separate file

parent 445dde8c
No related branches found
No related tags found
1 merge request!5MAINT: move datamodel config to a separate file
Pipeline #60964 passed with warnings
BUILD_MODULE_BOX_LOAN=ENABLED
/*
* This file is a part of the LinkAhead Project.
*
* Copyright (C) 2025 Henrik tom Wörden (h.tomwoerden@indiscale.com)
* Copyright (C) 2025 IndiScale GmbH (info@indiscale.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
var box_loan_config = function () {
var datamodel = {
loan: "Loan",
box: "Box",
returned: "returned",
}
var init = function () {
}
return {
init: init,
datamodel: datamodel
};
}();
$(document).ready(function() {
if ("${BUILD_MODULE_BOX_LOAN}" == "ENABLED") {
caosdb_modules.register(box_loan_config);
}
});
......@@ -43,22 +43,16 @@ var getHTMLForm = async function(pageName, variables) {
}
/**
* AWI Box Loan, refactored code.
* Box Loan, refactored code.
*/
var awi_box_loan = function () {
var box_loan = function (logger, box_loan_config) {
var logger = log.getLogger("awi_box_loan");
var datamodel = {
loan: "Loan",
box: "Box",
returned: "returned",
}
var datamodel = box_loan_config.datamodel;
const _dismiss_button = '<button class="btn btn-secondary box-loan-btn">OK</button>'
const _server_did_not_respond = "The server did not respond. Please reload the page.";
const _return_box_button = '<a title="Return Box." class="btn btn-link box-loan-btn">Return Box</a>';
const _borrow_box_button = '<a title="Borrow Box." class="btn btn-link box-loan-btn">Borrow Box</a>';
const _return_box_button = `<a title="Return ${datamodel.box}." class="btn btn-link box-loan-btn">Return ${datamodel.box}</a>`;
const _borrow_box_button = `<a title="Borrow ${datamodel.box}." class="btn btn-link box-loan-btn">Borrow ${datamodel.box}</a>`;
const _confirm_loan_button = '<a title="Confirm Loan." class="btn btn-link box-loan-btn">Confirm Loan</a>';
const _manual_return_button = '<a title="Manual Return." class="btn btn-link box-loan-btn">Manual Return</a>';
const _accept_return_button = '<a title="Accept Return" class="btn btn-link box-loan-btn">Accept Return</a>';
......@@ -747,9 +741,10 @@ var awi_box_loan = function () {
var init = function (boxes) {
const init_boxes = boxes || $(".caosdb-entity-panel")
.not("[data-version-successor]")
/* TODO: This fails easily (BoxType) */
.has(".caosdb-parent-name:contains('Box')")
.not(":has(.caosdb-parent-name:contains('BoxT'))").toArray();
.filter(function() {
return $(this).find(".caosdb-parent-name").text().trim() === datamodel.box;
})
.toArray();
add_buttons(init_boxes);
}
......@@ -760,13 +755,11 @@ var awi_box_loan = function () {
get_loan_state_string: get_loan_state_string,
};
}();
}(log.getLogger("box_loan"), box_loan_config);
/**
* Add the extensions to the webui.
*/
$(document).ready(function () {
// TODO build variable
awi_box_loan.init();
$(document).ready(function() {
if ("${BUILD_MODULE_BOX_LOAN}" == "ENABLED") {
caosdb_modules.register(box_loan);
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment