Skip to content

Commit

Permalink
Add option to configure whether IDs are automatic by default (#1019)
Browse files Browse the repository at this point in the history
* Add option to configure whether IDs are automatic by default

* Also enable for batch creation

* Patch new setting into docker builds
  • Loading branch information
ml-evs authored Nov 28, 2024
1 parent 58a6bc5 commit 0071652
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions .docker/app_dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ARG VUE_APP_HOMEPAGE_URL=magic-homepage-url
ARG VUE_APP_EDITABLE_INVENTORY=magic-setting
ARG VUE_APP_WEBSITE_TITLE=magic-title
ARG VUE_APP_QR_CODE_RESOLVER_URL=magic-qr-code-resolver-url
ARG VUE_APP_AUTOMATICALLY_GENERATE_ID_DEFAULT=magic-generate-id-setting

COPY webapp ./
RUN --mount=type=bind,target=/.git,src=./.git VUE_APP_GIT_VERSION=$(node scripts/get-version.js) /node_modules/.bin/vue-cli-service build
Expand Down
2 changes: 2 additions & 0 deletions .docker/app_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ echo " HOMEPAGE_URL: ${VUE_APP_HOMPAGE_URL}"
echo " EDITABLE_INVENTORY: ${VUE_APP_EDITABLE_INVENTORY}"
echo " WEBSITE_TITLE: ${VUE_APP_WEBSITE_TITLE}"
echo " QR_CODE_RESOLVER_URL: ${VUE_APP_QR_CODE_RESOLVER_URL}"
echo " AUTOMATICALLY_GENERATE_ID_DEFAULT: ${VUE_APP_AUTOMATICALLY_GENERATE_ID_DEFAULT}"
echo ""
echo "Patching..."

Expand All @@ -47,6 +48,7 @@ for file in $ROOT_DIR/js/app.*.js* $ROOT_DIR/*html; do
sed -i "s|magic-setting|${VUE_APP_EDITABLE_INVENTORY}|g" $file
sed -i "s|magic-title|${VUE_APP_WEBSITE_TITLE}|g" $file
sed -i "s|magic-qr-code-resolver-url|${VUE_APP_QR_CODE_RESOLVER_URL}|g" $file
sed -i "s|magic-generate-id-setting|${VUE_APP_AUTOMATICALLY_GENERATE_ID_DEFAULT}|g" $file
done

echo "Done!"
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
- VUE_APP_EDITABLE_INVENTORY
- VUE_APP_WEBSITE_TITLE
- VUE_APP_QR_CODE_RESOLVER_URL
- VUE_APP_AUTOMATICALLY_GENERATE_ID_DEFAULT
ports:
- "8081:8081"

Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/BatchCreateItemModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ import Modal from "@/components/Modal.vue";
import ItemSelect from "@/components/ItemSelect.vue";
import { createNewSamples } from "@/server_fetch_utils.js";
import { validateEntryID } from "@/field_utils.js";
import { itemTypes, SAMPLE_TABLE_TYPES } from "@/resources.js";
import { itemTypes, SAMPLE_TABLE_TYPES, AUTOMATICALLY_GENERATE_ID_DEFAULT } from "@/resources.js";
export default {
name: "BatchCreateItemModal",
components: {
Expand All @@ -356,7 +356,7 @@ export default {
epochStart: new Date("1970-01-01").toISOString().slice(0, -8),
oneYearOn: this.determineOneYearOn(),
nSamples: 3,
generateIDsAutomatically: false,
generateIDsAutomatically: AUTOMATICALLY_GENERATE_ID_DEFAULT,
item_type: "samples",
items: [
{
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/CreateItemModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ import Modal from "@/components/Modal.vue";
import ItemSelect from "@/components/ItemSelect.vue";
import { createNewItem } from "@/server_fetch_utils.js";
import { validateEntryID } from "@/field_utils.js";
import { itemTypes, SAMPLE_TABLE_TYPES } from "@/resources.js";
import { itemTypes, SAMPLE_TABLE_TYPES, AUTOMATICALLY_GENERATE_ID_DEFAULT } from "@/resources.js";
import CollectionSelect from "@/components/CollectionSelect.vue";
export default {
name: "CreateItemModal",
Expand Down Expand Up @@ -136,7 +136,7 @@ export default {
takenItemIds: [], // this holds ids that have been tried, whereas the computed takenSampleIds holds ids in the sample table
selectedItemToCopy: null,
startingConstituents: [],
generateIDAutomatically: false,
generateIDAutomatically: AUTOMATICALLY_GENERATE_ID_DEFAULT,
agesAgo: new Date("1970-01-01").toISOString().slice(0, -8), // a datetime for the unix epoch start
};
},
Expand Down
5 changes: 5 additions & 0 deletions webapp/src/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export const GRAVATAR_STYLE = "identicon";
const editable_inventory = process.env.VUE_APP_EDITABLE_INVENTORY || "false";
export const EDITABLE_INVENTORY = editable_inventory.toLowerCase() == "true";

const automatically_generate_id_default =
process.env.VUE_APP_AUTOMATICALLY_GENERATE_ID_DEFAULT || "false";
export const AUTOMATICALLY_GENERATE_ID_DEFAULT =
automatically_generate_id_default.toLowerCase() == "true";

// Eventually this should be pulled from the schema
export const DATETIME_FIELDS = new Set(["date"]);

Expand Down

0 comments on commit 0071652

Please sign in to comment.