LLEdit.vue 6.96 KB
Newer Older
Andrzej Obracaj's avatar
Andrzej Obracaj committed
1
<template>
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
2
3
4
5
6
7
8
  <l-modal
    :showing="showing"
    text="Observing Capabilities"
    icon="edit"
    color="bg-orange-500"
    @close="close"
  >
Andrzej Obracaj's avatar
Andrzej Obracaj committed
9
10
    <div class="w-full text-xs" v-if="editObj.id">
      <div class="w-full flex mb-4">
Andrzej Obracaj's avatar
Andrzej Obracaj committed
11
        <div class="w-1/2 mr-2">
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
12
13
14
          <b>Id</b>
          <br />
          <l-input
15
            placeholder="Enter unique Id"
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
16
17
18
19
            v-model="editObj.id"
            inputClass="text-2xs"
            :disabled="!this.isnew"
          ></l-input>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
20
        </div>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
21
        <div class="w-1/2">
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
22
23
24
25
26
27
28
          <b>Begin Position</b>
          <br />
          <l-input
            placeholder="YYYY-MM-DDTHH:mm:ss+hh:00"
            v-model="editObj.begin_position"
            inputClass="text-2xs"
          ></l-input>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
29
30
31
        </div>
      </div>
      <div class="w-full flex mb-4">
Andrzej Obracaj's avatar
Andrzej Obracaj committed
32
        <div class="w-1/2 mr-2">
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
33
34
35
36
          <b>End Position</b>
          <br />
          <l-input
            placeholder="YYYY-MM-DDTHH:mm:ss+hh:00 (optional)"
Andrzej Obracaj's avatar
bug    
Andrzej Obracaj committed
37
            v-model="editObj.end_position"
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
38
39
            inputClass="text-2xs"
          ></l-input>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
40
        </div>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
41
        <div class="w-1/2">
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
          <b>Process Type</b>
          <br />
          <l-select
            v-model="editObj.process_type"
            class="text-xs"
            :data="processtypevalues"
            :multiple="false"
          >
            <l-option
              v-for="i in processtypevalues"
              :key="i.value"
              class="text-xs"
              :value="i.value"
              :label="i.label"
            />
Andrzej Obracaj's avatar
Andrzej Obracaj committed
57
          </l-select>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
58
        </div>
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
59
      </div>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
60
      <div class="w-full flex mb-4">
Andrzej Obracaj's avatar
Andrzej Obracaj committed
61
        <div class="w-1/2 mr-2">
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
          <b>Result Nature</b>
          <br />
          <l-select
            v-model="editObj.result_nature"
            class="text-xs"
            :data="resultnaturevalues"
            :multiple="false"
          >
            <l-option
              v-for="i in resultnaturevalues"
              :key="i.value"
              class="text-xs"
              :value="i.value"
              :label="i.label"
            />
          </l-select>
        </div>

Andrzej Obracaj's avatar
Andrzej Obracaj committed
80
        <div class="w-1/2">
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
          <b>Pollutant</b>
          <br />
          <l-select
            v-model="editObj.pollutant"
            class="text-xs"
            :data="pollutants"
            :multiple="false"
          >
            <l-option
              v-for="i in pollutants"
              :key="i.value"
              class="text-xs"
              :value="i.value"
              :label="i.label"
            />
          </l-select>
        </div>
      </div>
      <div class="w-full flex mb-4">
        <div class="w-1/2 mr-2">
          <b>Concentration</b>
          <br />
          <l-select
            v-model="editObj.concentration"
            class="text-xs"
            :data="concentrations"
            :multiple="false"
          >
            <l-option
              v-for="i in concentrations"
              :key="i.value"
              class="text-xs"
              :value="i.value"
              :label="i.label"
            />
          </l-select>
        </div>
        <div class="w-1/2">
          <b>Time step</b>
          <br />
          <l-select v-model="editObj.timestep" class="text-xs" :data="timesteps" :multiple="false">
            <l-option
              v-for="i in timesteps"
              :key="i.value"
              class="text-xs"
              :value="i.value"
              :label="i.label"
            />
          </l-select>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
130
        </div>
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
131
      </div>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
132
      <div class="w-full flex mb-4">
Andrzej Obracaj's avatar
Andrzej Obracaj committed
133
        <div class="w-1/2 mr-2">
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
          <b>Sampling Point ID</b>
          <br />
          <l-select
            v-model="editObj.sampling_point_id"
            class="text-xs"
            :data="samplingpoints"
            :multiple="false"
          >
            <l-option
              v-for="i in samplingpoints"
              :key="i.value"
              class="text-xs"
              :value="i.value"
              :label="i.label"
            />
          </l-select>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
150
        </div>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
151
        <div class="w-1/2">
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
          <b>Process ID</b>
          <br />
          <l-select
            v-model="editObj.process_id"
            class="text-xs"
            :data="processes"
            :multiple="false"
          >
            <l-option
              v-for="i in processes"
              :key="i.value"
              class="text-xs"
              :value="i.value"
              :label="i.label"
            />
          </l-select>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
168
        </div>
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
169
      </div>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
170
      <div class="w-full flex mb-4">
Andrzej Obracaj's avatar
Andrzej Obracaj committed
171
        <div class="w-1/2 mr-2">
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
172
173
174
175
176
177
178
179
180
181
182
          <b>Sample ID</b>
          <br />
          <l-select v-model="editObj.sample_id" class="text-xs" :data="samples" :multiple="false">
            <l-option
              v-for="i in samples"
              :key="i.value"
              class="text-xs"
              :value="i.value"
              :label="i.label"
            />
          </l-select>
Andrzej Obracaj's avatar
Andrzej Obracaj committed
183
        </div>
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
184
185
      </div>

Andrzej Obracaj's avatar
Andrzej Obracaj committed
186
187
188
189
190
191
192
193
194
195
196
197
198
199
      <div class="flex w-full justify-between">
        <l-button type="success" @click="onSave">Save changes</l-button>
        <l-button type="danger" @click="close">Cancel</l-button>
      </div>
    </div>
  </l-modal>
</template>

<script>
import LModal from "@/components/LModal";
import { LInput, LButton, LSelect, LOption } from "@/components/forms";

export default {
  name: "LLEdit",
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
200
201
202
203
204
205
206
207
208
209
210
211
212
213
  props: [
    "showing",
    "observing_capabilities",
    "processtypevalues",
    "resultnaturevalues",
    "pollutants",
    "concentrations",
    "timesteps",
    "samplingpoints",
    "processes",
    "samples",
    "selected",
    "isnew"
  ],
Andrzej Obracaj's avatar
Andrzej Obracaj committed
214
215
216
217
218
219
220
221
222
223
224
225
  components: {
    LModal,
    LInput,
    LButton,
    LSelect,
    LOption
  },
  computed: {
    editObj: function() {
      return Object.assign({}, this.selected);
    }
  },
Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
226
  methods: {
Andrzej Obracaj's avatar
Andrzej Obracaj committed
227
228
229
230
    close() {
      this.$emit("close");
    },
    onSave() {
231
      // debugger;
Christoffer Stoll's avatar
Christoffer Stoll committed
232
      const pt = this.processtypevalues.find(
Andrzej Obracaj's avatar
Andrzej Obracaj committed
233
        r => r.value == this.editObj.process_type
Andrzej Obracaj's avatar
Andrzej Obracaj committed
234
      );
Andrzej Obracaj's avatar
Andrzej Obracaj committed
235
      this.editObj.process_type_name = pt.label;
Andrzej Obracaj's avatar
Andrzej Obracaj committed
236
237

      const rn = this.resultnaturevalues.find(
Andrzej Obracaj's avatar
Andrzej Obracaj committed
238
        r => r.value == this.editObj.result_nature
Andrzej Obracaj's avatar
Andrzej Obracaj committed
239
      );
Andrzej Obracaj's avatar
Andrzej Obracaj committed
240
      this.editObj.result_nature_name = rn.label;
Andrzej Obracaj's avatar
Andrzej Obracaj committed
241

Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
242
      const p = this.pollutants.find(r => r.value == this.editObj.pollutant);
Andrzej Obracaj's avatar
Andrzej Obracaj committed
243
      this.editObj.pollutant_name = p.label;
Andrzej Obracaj's avatar
Andrzej Obracaj committed
244

Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
245
246
247
248
249
250
251
252
      const c = this.concentrations.find(
        r => r.value == this.editObj.concentration
      );
      this.editObj.concentration_name = c.label;

      const t = this.timesteps.find(r => r.value == this.editObj.timestep);
      this.editObj.timestep_name = t.label;

Andrzej Obracaj's avatar
Andrzej Obracaj committed
253
254
255
256
257
      const sp = this.samplingpoints.find(
        r => r.value == this.editObj.sampling_point_id
      );
      this.editObj.sampling_point_id = sp.label;

Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
258
      const pr = this.processes.find(r => r.value == this.editObj.process_id);
Andrzej Obracaj's avatar
Andrzej Obracaj committed
259
260
      this.editObj.process_id = pr.label;

Rune Åvar Ødegård's avatar
Rune Åvar Ødegård committed
261
262
      const s = this.samples.find(r => r.value == this.editObj.sample_id);
      this.editObj.sample_id = s.label;
Andrzej Obracaj's avatar
Andrzej Obracaj committed
263

Andrzej Obracaj's avatar
Andrzej Obracaj committed
264
265
266
267
268
269
      this.$emit("save", this.editObj);
      this.close();
    }
  }
};
</script>