Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntitySelect widget multiple option not working #47

Closed
symbioquine opened this issue Apr 12, 2024 · 1 comment
Closed

EntitySelect widget multiple option not working #47

symbioquine opened this issue Apr 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@symbioquine
Copy link
Owner

symbioquine commented Apr 12, 2024

The multiple option to the EntitySelect component doesn't seem to be working...

When the multiple prop is set to true, clicking on the options doesn't seem to do anything.

ExampleChildrenSelection.alink.vue

<script setup>
import { computed, ref} from 'vue';

const selectedParents = ref([]);
const selectedChild = ref(undefined);

const childrenFilter = computed(() => {
  if (!selectedParents.value.length) {
    return [];
  }
  return [{
    kind: 'group',
    op: 'AND',
    filter: selectedParents.value.map(selectedParent => ({
      // This inner OR group shouldn't be needed, but there is a bug in how
      // multiple conditions against the same field are handled in Drupal Core
      // https://www.drupal.org/project/drupal/issues/3066202#comment-13181270
      kind: 'group',
      op: 'OR',
      filter: [{
        kind: 'attribute',
        attribute: 'parent.id',
        op: '=',
        value: selectedParent.id
      }]
    }))
  }];
});
</script>

<template alink-route[com.example.farmos_asset_link.routes.v0.example_children_selection_page]="/select-parent-child">
  <q-page padding class="text-left">
    <h4 class="q-mb-md q-mt-xs">Select parents and a child</h4>

    <p><b>Parents:</b> {{ selectedParents.map(sp => sp.attributes.drupal_internal__id + ' ' + sp.attributes.name ) }}</p>

    <p><b>Child:</b> {{ selectedChild?.attributes?.drupal_internal__id }} {{ selectedChild?.attributes?.name }}</p>

    <entity-select
      label="Parent Assets"
      entity-type="asset"
      v-model="selectedParents"
      :multiple="true"
    ></entity-select>

    <entity-select
      label="Child Asset"
      entity-type="asset"
      v-model="selectedChild"
      :additional-filters="childrenFilter"
    ></entity-select>

  </q-page>
</template>

<script>
import { h } from 'vue';
import { QBtn } from 'quasar';

export default {
  onLoad(handle, assetLink) {
    handle.defineSlot('com.example.farmos_asset_link.tb_item.v0.example_children_selection_button', slot => {
      slot.type('toolbar-item');
      slot.weight(20);
      slot.component(() => h(QBtn, { flat: true, dense: true, icon: "mdi-human-male-girl", to: '/select-parent-child' }));
    });
  }
}
</script>

EDIT: Updated script above to actually implement the multiple parent filtering "correctly" (i.e. in a way that works - albeit in a round-about manner).

@symbioquine symbioquine added the bug Something isn't working label Apr 12, 2024
@symbioquine
Copy link
Owner Author

This fix was released in 1.0.0-alpha13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant