diff --git a/src/components/Form/fields/Autosuggest.vue b/src/components/Form/fields/Autosuggest.vue
index 72b75907e..36fc5790c 100644
--- a/src/components/Form/fields/Autosuggest.vue
+++ b/src/components/Form/fields/Autosuggest.vue
@@ -18,7 +18,7 @@
>
- {{ deselectLabel.replace('{$item}', item.label) }}
+ {{ deselectLabel?.replace('{$item}', item.label) }}
@@ -31,48 +31,72 @@
@update:model-value="selectSuggestion"
>
handleChange(event)"
- @focus="() => handleFocus()"
- @blur="() => handleBlur()"
+ @focus="() => handleFocus(true)"
+ @blur="() => handleFocus(false)"
/>
- {{ localInputValue }}
+
+ {{ t('common.loading') }}
-
- {{ suggestion.label }}
+ {{ localInputValue }}
+
+
+
+
+ {{ suggestion.label }}
+
+
+
@@ -86,6 +110,7 @@ import {
} from '@headlessui/vue';
import PkpBadge from '@/components/Badge/Badge.vue';
import Icon from '@/components/Icon/Icon.vue';
+import Spinner from '@/components/Spinner/Spinner.vue';
const slots = useSlots();
@@ -94,10 +119,6 @@ const props = defineProps({
type: String,
required: true,
},
- inputProps: {
- type: Object,
- required: true,
- },
suggestions: {
type: Array,
default: () => [],
@@ -122,36 +143,54 @@ const props = defineProps({
type: String,
default: () => '',
},
- isFocused: {
+ isLoading: {
type: Boolean,
default: () => false,
},
+ inputDescribedByIds: {
+ type: String,
+ required: true,
+ },
+ inputControlId: {
+ type: String,
+ required: true,
+ },
+ inputName: {
+ type: String,
+ default: () => 'autosuggest',
+ },
});
+/**
+ * Props to pass to the input field
+ */
+const inputProps = {
+ 'aria-describedby': props.inputDescribedByIds,
+ class: 'pkpAutosuggest__input',
+ id: props.inputControlId,
+ name: props.inputName,
+ disabled: props.isDisabled,
+};
+
const emit = defineEmits([
'update:inputValue',
- 'update:isFocused',
+ 'focus-changed',
'select-suggestion',
'deselect',
]);
const allowCustom = inject('allowCustom', false);
const localInputValue = ref('');
-const localIsFocused = ref(props.isFocused);
+const isFocused = ref(false);
function handleChange(event) {
localInputValue.value = event.target.value.trim();
emit('update:inputValue', localInputValue.value);
}
-function handleFocus() {
- localIsFocused.value = true;
- emit('update:isFocused', localIsFocused.value);
-}
-
-function handleBlur() {
- localIsFocused.value = false;
- emit('update:isFocused', localIsFocused.value);
+function handleFocus(state) {
+ isFocused.value = state;
+ emit('focus-changed', state);
}
function selectSuggestion(suggestion) {
@@ -161,4 +200,6 @@ function selectSuggestion(suggestion) {
function deselect(item) {
emit('deselect', item);
}
+
+defineExpose({handleFocus});
diff --git a/src/components/Form/fields/FieldBaseAutosuggest.stories.js b/src/components/Form/fields/FieldBaseAutosuggest.stories.js
index 453ddd119..b5abd178b 100644
--- a/src/components/Form/fields/FieldBaseAutosuggest.stories.js
+++ b/src/components/Form/fields/FieldBaseAutosuggest.stories.js
@@ -112,12 +112,12 @@ const RORExample = {
);
const suggestions = items
- .filter((u) => u.fullName.match(regex))
+ .filter((u) => u.name.match(regex))
.filter((u) => !this.currentValue.includes(u.id))
.map((u) => {
return {
value: u.id,
- label: u.fullName,
+ label: u.name,
hasSlot: u.ror,
};
});
diff --git a/src/components/Form/fields/FieldBaseAutosuggest.vue b/src/components/Form/fields/FieldBaseAutosuggest.vue
index 086a1f505..4ac7d32ae 100644
--- a/src/components/Form/fields/FieldBaseAutosuggest.vue
+++ b/src/components/Form/fields/FieldBaseAutosuggest.vue
@@ -45,7 +45,7 @@
:class="{
'pkpAutosuggest__inputWrapper--multilingual':
isMultilingual && locales.length > 1,
- 'pkpAutosuggest__inputWrapper--focus': isFocused,
+ 'pkpAutosuggest__inputWrapper--focus': inputFocused,
}"
@click="setFocusToInput"
>
@@ -83,11 +83,11 @@
@@ -194,7 +194,7 @@ export default {
data() {
return {
inputValue: '',
- isFocused: false,
+ inputFocused: false,
suggestions: [],
};
},
@@ -242,24 +242,6 @@ export default {
);
},
- /**
- * Props to pass to the input field
- *
- * @return {Object}
- */
- inputProps() {
- let props = {
- 'aria-describedby': this.describedByIds,
- class: 'pkpAutosuggest__input',
- id: this.controlId,
- name: this.name,
- };
- if (this.isDisabled) {
- props.disabled = 'disabled';
- }
- return props;
- },
-
/**
* Is this field in a right-to-left language
*/
@@ -270,12 +252,14 @@ export default {
autoSuggestProps() {
return {
id: this.autosuggestId,
- inputProps: this.inputProps,
suggestions: this.suggestions,
selectedLabel: this.selectedLabel,
currentSelected: this.currentSelected,
isDisabled: this.isDisabled,
deselectLabel: this.deselectLabel,
+ inputDescribedByIds: this.describedByIds,
+ inputControlId: this.controlId,
+ inputName: this.name,
};
},
},
@@ -319,7 +303,14 @@ export default {
return;
}
- this.$refs.cb.$refs.autosuggestInput.$el.focus();
+ this.$refs.inputRef.handleFocus(true);
+ },
+
+ /**
+ * Change the input focus state
+ */
+ changeFocus(state) {
+ this.inputFocused = state;
},
/**
diff --git a/src/components/Form/fields/FieldRorAutosuggest.stories.js b/src/components/Form/fields/FieldRorAutosuggest.stories.js
new file mode 100644
index 000000000..2c6053208
--- /dev/null
+++ b/src/components/Form/fields/FieldRorAutosuggest.stories.js
@@ -0,0 +1,24 @@
+import FieldRorAutosuggest from './FieldRorAutosuggest.vue';
+
+export default {
+ title: 'Components/FieldRorAutosuggest',
+ component: FieldRorAutosuggest,
+ render: (args) => ({
+ components: {FieldRorAutosuggest},
+ setup() {
+ return {args};
+ },
+ template: '',
+ }),
+};
+
+export const Default = {
+ render: (args) => ({
+ components: {FieldRorAutosuggest},
+ setup() {
+ return {args};
+ },
+ template: '',
+ }),
+ args: {},
+};
diff --git a/src/components/Form/fields/FieldRorAutosuggest.vue b/src/components/Form/fields/FieldRorAutosuggest.vue
new file mode 100644
index 000000000..e6fbb9bf4
--- /dev/null
+++ b/src/components/Form/fields/FieldRorAutosuggest.vue
@@ -0,0 +1,155 @@
+
+
+
+
+
diff --git a/src/mocks/institutions.json b/src/mocks/institutions.json
index 476d5fd61..231481d80 100644
--- a/src/mocks/institutions.json
+++ b/src/mocks/institutions.json
@@ -2,52 +2,52 @@
"items": [
{
"id": 1,
- "fullName": "University of Toronto",
+ "name": "University of Toronto",
"ror": true
},
{
"id": 2,
- "fullName": "University of Bath",
+ "name": "University of Bath",
"ror": true
},
{
"id": 3,
- "fullName": "University of Melbourne",
+ "name": "University of Melbourne",
"ror": true
},
{
"id": 4,
- "fullName": "Technical University of Berlin",
+ "name": "Technical University of Berlin",
"ror": true
},
{
"id": 5,
- "fullName": "University of West Los Angeles",
+ "name": "University of West Los Angeles",
"ror": true
},
{
"id": 6,
- "fullName": "Niagara College",
+ "name": "Niagara College",
"ror": true
},
{
"id": 7,
- "fullName": "Innovate Niagara",
+ "name": "Innovate Niagara",
"ror": true
},
{
"id": 8,
- "fullName": "Regional Municipality of Niagara",
+ "name": "Regional Municipality of Niagara",
"ror": true
},
{
"id": 9,
- "fullName": "Niagara University",
+ "name": "Niagara University",
"ror": true
},
{
"id": 10,
- "fullName": "Niagara Association of Medicine"
+ "name": "Niagara Association of Medicine"
}
],
"itemsMax": 10