Mercurial > gemma
changeset 2366:ff1e4f1b54c6
agm_import: originator field added
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 21 Feb 2019 09:58:24 +0100 |
parents | 242c170e00ce |
children | 0aedae39726e |
files | client/src/components/ImportApprovedGaugeMeasurement.vue |
diffstat | 1 files changed, 58 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/ImportApprovedGaugeMeasurement.vue Thu Feb 21 09:31:02 2019 +0100 +++ b/client/src/components/ImportApprovedGaugeMeasurement.vue Thu Feb 21 09:58:24 2019 +0100 @@ -12,37 +12,53 @@ </h6> <div class="card-body stretches-card"> <div class="w-95 ml-auto mr-auto mt-4 mb-4"> - <div class="d-flex flex-row input-group mb-4"> - <div class="flex-column w-100"> - <div class="custom-file"> - <input - accept=".csv" - type="file" - @change="fileSelected" - class="custom-file-input" - id="uploadFile" - /> - <label class="pointer custom-file-label" for="uploadFile"> - {{ uploadLabel }} - </label> - </div> + <div class="d-flex flex-column text-left w-25"> + <label class="text-nowrap" for="originator"> + <small class="text-muted" + >{{ $options.ORIGINATOR }} / {{ $options.FROM }}</small + > + </label> + <input + type="text" + v-model="originator" + class="form-control" + id="originator" + /> + <span class="text-left text-danger"> + <small v-if="!originator"> + <translate>Please enter an originator</translate> + </small> + </span> + </div> + <div class="mt-4 flex-column w-100"> + <div class="custom-file"> + <input + accept=".csv" + type="file" + @change="fileSelected" + class="custom-file-input" + id="uploadFile" + /> + <label class="pointer custom-file-label" for="uploadFile"> + {{ uploadLabel }} + </label> </div> </div> - <div class="buttons text-right"> - <button - :disabled="disableUploadButton" - @click="submit" - class="btn btn-info mt-4" - type="button" - > - <font-awesome-icon - class="fa-fw mr-2" - fixed-width - icon="play" - ></font-awesome-icon> - <translate>Trigger import</translate> - </button> - </div> + </div> + <div class="buttons text-right"> + <button + :disabled="disableUploadButton" + @click="submit" + class="btn btn-info mt-4" + type="button" + > + <font-awesome-icon + class="fa-fw mr-2" + fixed-width + icon="play" + ></font-awesome-icon> + <translate>Trigger import</translate> + </button> </div> </div> </div> @@ -66,6 +82,7 @@ import { HTTP } from "@/lib/http"; import { displayError, displayInfo } from "@/lib/errors.js"; +import app from "@/main"; export default { name: "importapprovedgaugemeasurements", @@ -73,10 +90,16 @@ return { disableUploadButton: false, uploadLabel: this.$gettext("choose file to upload"), - uploadFile: null + uploadFile: null, + originator: "viadonau" }; }, methods: { + initialState() { + this.uploadLabel = this.$gettext("choose file to upload"); + this.uploadFile = null; + this.originator = "viadonau"; + }, fileSelected(e) { const files = e.target.files || e.dataTransfer.files; if (!files) return; @@ -84,9 +107,10 @@ this.uploadFile = files[0]; }, submit() { - if (!this.uploadFile) return; + if (!this.originator || !this.uploadFile) return; let formData = new FormData(); formData.append("agm", this.uploadFile); + formData.append("originator", this.originator); HTTP.post("/imports/agm", formData, { headers: { "X-Gemma-Auth": localStorage.getItem("token"), @@ -113,7 +137,9 @@ }, components: { Spacer: () => import("./Spacer") - } + }, + ORIGINATOR: app.$gettext("originator"), + FROM: app.$gettext("from") }; </script>