22import { library } from " @fortawesome/fontawesome-svg-core" ;
33import { faEdit } from " @fortawesome/free-solid-svg-icons" ;
44import { FontAwesomeIcon } from " @fortawesome/vue-fontawesome" ;
5+ import { BAlert } from " bootstrap-vue" ;
6+ import LoadingSpan from " components/LoadingSpan" ;
57import RuleCollectionBuilder from " components/RuleCollectionBuilder" ;
68import RulesDisplay from " components/RulesDisplay/RulesDisplay" ;
79import { computed , ref } from " vue" ;
810
911import { fetchCollectionDetails } from " @/api/datasetCollections" ;
12+ import { errorMessageAsString } from " @/utils/simple-error" ;
1013
1114library .add (faEdit);
1215
@@ -22,6 +25,8 @@ const props = defineProps({
2225
2326const modal = ref (null );
2427const elements = ref (null );
28+ const loading = ref (false );
29+ const loadError = ref ();
2530
2631const initialRules = {
2732 rules: [],
@@ -33,12 +38,17 @@ const displayRules = computed(() => props.value ?? initialRules);
3338async function onEdit () {
3439 if (props .target ) {
3540 try {
41+ loading .value = true ;
42+ loadError .value = undefined ;
3643 const collectionDetails = await fetchCollectionDetails ({ id: props .target .id });
3744 elements .value = collectionDetails;
3845 modal .value .show ();
3946 } catch (e) {
47+ loadError .value = errorMessageAsString (e);
4048 console .error (e);
4149 console .log (" problem fetching collection" );
50+ } finally {
51+ loading .value = false ;
4252 }
4353 } else {
4454 modal .value .show ();
@@ -64,7 +74,10 @@ function onCancel() {
6474 < FontAwesomeIcon icon= " fa-edit" / >
6575 < span> Edit< / span>
6676 < / b- button>
67-
77+ < LoadingSpan v- if = " loading" message= " Loading collection details" > < / LoadingSpan>
78+ < BAlert v- if = " loadError" show variant= " danger" dismissible @dismissed= " loadError = undefined" >
79+ {{ loadError }}
80+ < / BAlert>
6881 < b- modal ref= " modal" modal- class = " ui-form-rules-edit-modal" hide- footer>
6982 < template v- slot: modal- title>
7083 < h2 class = " mb-0" > Build Rules for Applying to Existing Collection< / h2>
0 commit comments