@geode/opengeodeweb-front 10.22.0-rc.1 → 10.22.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,7 +64,7 @@ await get_allowed_files();
64
64
  accept,
65
65
  files: internal_files,
66
66
  auto_upload: internal_auto_upload,
67
- show_overlay,
67
+ showOverlay: show_overlay,
68
68
  }"
69
69
  @files_uploaded="files_uploaded_event"
70
70
  />
@@ -17,6 +17,7 @@ const backStore = useBackStore();
17
17
  const loading = ref(false);
18
18
  const allowed_objects = ref({});
19
19
  const toggle_loading = useToggle(loading);
20
+ const multiple_files_no_common = ref(false);
20
21
 
21
22
  function select_geode_object(object_map) {
22
23
  const object_keys = Object.keys(object_map);
@@ -51,12 +52,18 @@ function select_geode_object(object_map) {
51
52
  async function get_allowed_objects() {
52
53
  toggle_loading();
53
54
  allowed_objects.value = {};
55
+ multiple_files_no_common.value = false;
54
56
 
55
57
  const promise_array = filenames.map((filename) => backStore.request(schema, { filename }));
56
58
  const responses = await Promise.all(promise_array);
57
59
  const allowed_objects_list = responses.map((response) => response.allowed_objects);
58
60
  const all_keys = [...new Set(allowed_objects_list.flatMap((obj) => Object.keys(obj)))];
59
61
  const common_keys = all_keys.filter((key) => allowed_objects_list.every((obj) => key in obj));
62
+
63
+ if (filenames.length > 1 && all_keys.length > 0 && common_keys.length === 0) {
64
+ multiple_files_no_common.value = true;
65
+ }
66
+
60
67
  const final_object = {};
61
68
  for (const key of common_keys) {
62
69
  const load_scores = allowed_objects_list.map((obj) => obj[key].is_loadable);
@@ -127,6 +134,13 @@ await get_allowed_objects();
127
134
  </v-tooltip>
128
135
  </v-col>
129
136
  </v-row>
137
+ <v-row v-else-if="multiple_files_no_common" class="pa-5">
138
+ <v-card class="card" variant="tonal" rounded>
139
+ <v-card-text>
140
+ These files cannot be loaded together because they don't share a common data type.
141
+ </v-card-text>
142
+ </v-card>
143
+ </v-row>
130
144
  <v-row v-else class="pa-5">
131
145
  <v-card class="card" variant="tonal" rounded>
132
146
  <v-card-text>
@@ -6,34 +6,15 @@ function truncate(text, maxLength) {
6
6
  return text;
7
7
  }
8
8
 
9
- const { step_index } = defineProps({
9
+ const { step_index, stepper_tree } = defineProps({
10
10
  step_index: { type: Number, required: true },
11
+ stepper_tree: { type: Object, required: true },
11
12
  });
12
13
 
13
14
  const emit = defineEmits(["reset_values"]);
14
15
 
15
- const stepper_tree = inject("stepper_tree");
16
- const { current_step_index, steps } = toRefs(stepper_tree);
17
-
18
- watch(current_step_index, (newVal, oldVal) => {
19
- if (newVal < oldVal) {
20
- stepper_tree.navigating_back = true;
21
- }
22
- });
23
-
24
- function update_values_event(keys_values_object) {
25
- for (const [key, value] of Object.entries(keys_values_object)) {
26
- stepper_tree[key] = value;
27
- }
28
- }
29
-
30
- function increment_step() {
31
- stepper_tree.current_step_index += 1;
32
- }
33
-
34
- function decrement_step() {
35
- stepper_tree.current_step_index -= 1;
36
- }
16
+ const { state, increment_step, decrement_step, update_values } = stepper_tree;
17
+ const { current_step_index, steps } = toRefs(state);
37
18
 
38
19
  const sortedChips = computed(() => {
39
20
  const chips = steps.value[step_index]?.chips || [];
@@ -92,7 +73,7 @@ const sortedChips = computed(() => {
92
73
  v-bind="steps[step_index].component.component_options"
93
74
  @increment_step="increment_step"
94
75
  @decrement_step="decrement_step"
95
- @update_values="update_values_event"
76
+ @update_values="update_values"
96
77
  @reset_values="emit('reset_values')"
97
78
  />
98
79
  </v-card-text>
@@ -2,8 +2,11 @@
2
2
  import Step from "@ogw_front/components/Step";
3
3
 
4
4
  const emit = defineEmits(["reset_values", "close"]);
5
- const stepper_tree = inject("stepper_tree");
6
- const { steps, current_step_index } = toRefs(stepper_tree);
5
+ const { stepper_tree } = defineProps({
6
+ stepper_tree: { type: Object, required: true },
7
+ });
8
+ const { state } = stepper_tree;
9
+ const { steps, current_step_index } = toRefs(state);
7
10
  </script>
8
11
 
9
12
  <template>
@@ -28,6 +31,7 @@ const { steps, current_step_index } = toRefs(stepper_tree);
28
31
  v-for="(step, index) in steps"
29
32
  :key="index"
30
33
  :step_index="index"
34
+ :stepper_tree="stepper_tree"
31
35
  @reset_values="emit('reset_values')"
32
36
  />
33
37
  </v-stepper-vertical>
@@ -0,0 +1,56 @@
1
+ export function useStepperTree(steps, initial_state = {}) {
2
+ const initial_state_unref = {};
3
+ for (const [key, value] of Object.entries(initial_state)) {
4
+ const unref_val = unref(value);
5
+ if (Array.isArray(unref_val)) {
6
+ initial_state_unref[key] = [...unref_val];
7
+ } else {
8
+ initial_state_unref[key] = unref_val;
9
+ }
10
+ }
11
+ const state = reactive({
12
+ current_step_index: 0,
13
+ navigating_back: false,
14
+ steps,
15
+ ...initial_state,
16
+ });
17
+
18
+ watch(
19
+ () => state.current_step_index,
20
+ (newVal, oldVal) => {
21
+ if (newVal < oldVal) {
22
+ state.navigating_back = true;
23
+ }
24
+ },
25
+ );
26
+
27
+ function update_values(keys_values_object) {
28
+ for (const [key, value] of Object.entries(keys_values_object)) {
29
+ state[key] = value;
30
+ }
31
+ }
32
+
33
+ function increment_step() {
34
+ state.current_step_index += 1;
35
+ }
36
+
37
+ function decrement_step() {
38
+ state.current_step_index -= 1;
39
+ }
40
+
41
+ function reset_values() {
42
+ state.current_step_index = 0;
43
+ state.navigating_back = false;
44
+ for (const [key, initial_val] of Object.entries(initial_state_unref)) {
45
+ state[key] = Array.isArray(initial_val) ? [...initial_val] : initial_val;
46
+ }
47
+ }
48
+
49
+ return {
50
+ state,
51
+ update_values,
52
+ increment_step,
53
+ decrement_step,
54
+ reset_values,
55
+ };
56
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geode/opengeodeweb-front",
3
- "version": "10.22.0-rc.1",
3
+ "version": "10.22.0-rc.3",
4
4
  "description": "OpenSource Vue/Nuxt/Pinia/Vuetify framework for web applications",
5
5
  "homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Front",
6
6
  "bugs": {
@@ -1,10 +1,11 @@
1
- import { computed, reactive, ref, shallowRef } from "vue";
1
+ import { computed, ref, shallowRef } from "vue";
2
2
  import { describe, expect, test } from "vitest";
3
3
  import ResizeObserver from "resize-observer-polyfill";
4
4
  import { mount } from "@vue/test-utils";
5
5
 
6
6
  import ObjectSelector from "@ogw_front/components/ObjectSelector";
7
7
  import Step from "@ogw_front/components/Step";
8
+ import { useStepperTree } from "@ogw_front/composables/stepper_tree.js";
8
9
 
9
10
  import { vuetify } from "@ogw_tests/utils";
10
11
 
@@ -14,10 +15,8 @@ describe("step", () => {
14
15
  test("brep", () => {
15
16
  const geode_object_type = ref("BRep");
16
17
  const files = ref([]);
17
- const stepper_tree = reactive({
18
- current_step_index: ref(0),
19
- geode_object_type,
20
- steps: [
18
+ const stepper_tree = useStepperTree(
19
+ [
21
20
  {
22
21
  step_title: "Confirm the data type",
23
22
  component: {
@@ -30,13 +29,13 @@ describe("step", () => {
30
29
  chips: computed(() => [geode_object_type.value].filter((chip) => chip !== "")),
31
30
  },
32
31
  ],
33
- });
32
+ { geode_object_type },
33
+ );
34
34
  const wrapper = mount(Step, {
35
35
  global: {
36
36
  plugins: [vuetify],
37
- provide: { stepper_tree },
38
37
  },
39
- props: { step_index: 0 },
38
+ props: { step_index: 0, stepper_tree },
40
39
  });
41
40
  expect(wrapper.exists()).toBe(true);
42
41
  });
@@ -1,15 +1,12 @@
1
- // Third party imports
2
- import { computed, reactive, ref, shallowRef } from "vue";
1
+ import { computed, ref, shallowRef } from "vue";
3
2
  import { describe, expect, test } from "vitest";
4
- import ResizeObserver from "resize-observer-polyfill";
5
3
  import { mountSuspended } from "@nuxt/test-utils/runtime";
4
+ import { useStepperTree } from "@ogw_front/composables/stepper_tree.js";
5
+ import { vuetify } from "@ogw_tests/utils";
6
6
 
7
- // Local imports
8
7
  import ObjectSelector from "@ogw_front/components/ObjectSelector";
8
+ import ResizeObserver from "resize-observer-polyfill";
9
9
  import Stepper from "@ogw_front/components/Stepper";
10
- import { vuetify } from "@ogw_tests/utils";
11
-
12
- const FIRST_INDEX = 0;
13
10
 
14
11
  globalThis.ResizeObserver = ResizeObserver;
15
12
 
@@ -17,10 +14,8 @@ describe("stepper", () => {
17
14
  test("mount", async () => {
18
15
  const geode_object_type = ref("BRep");
19
16
  const files = ref([]);
20
- const stepper_tree = reactive({
21
- current_step_index: ref(FIRST_INDEX),
22
- geode_object_type,
23
- steps: [
17
+ const stepper_tree = useStepperTree(
18
+ [
24
19
  {
25
20
  step_title: "Confirm the data type",
26
21
  component: {
@@ -33,12 +28,13 @@ describe("stepper", () => {
33
28
  chips: computed(() => [geode_object_type.value].filter((chip) => chip !== "")),
34
29
  },
35
30
  ],
36
- });
31
+ { geode_object_type },
32
+ );
37
33
  const wrapper = await mountSuspended(Stepper, {
38
34
  global: {
39
35
  plugins: [vuetify],
40
- provide: { stepper_tree },
41
36
  },
37
+ props: { stepper_tree },
42
38
  });
43
39
  expect(wrapper.exists()).toBe(true);
44
40
  });