Allow injecting widgets into all object views #122

Closed
opened 2020-01-01 16:08:54 +01:00 by nik · 28 comments
Owner

All apps should be able to inject snippets into object views. Examples:

  • Exlibris could add a list of borrowed books to the Person view
  • Chronos could add the current lesson to a class group view
All apps should be able to inject snippets into object views. Examples: * Exlibris could add a list of borrowed books to the Person view * Chronos could add the current lesson to a class group view
Author
Owner

removed milestone

removed milestone
Author
Owner

closed

closed
Author
Owner

assigned to @nik

assigned to @nik
Author
Owner

marked this issue as related to #73

marked this issue as related to #73
Author
Owner

We should create an ExtensibleView that provides an API for other apps to inject templates and contexts, which are then handled by the view, e.g. by rendering the template snippets in tabs/eidgets/etc.

We should create an `ExtensibleView` that provides an API for other apps to inject templates and contexts, which are then handled by the view, e.g. by rendering the template snippets in tabs/eidgets/etc.
Owner

mentioned in merge request Teckids/ticdesk!1700

mentioned in merge request Teckids/ticdesk!1700
Member

mentioned in issue #539

mentioned in issue #539
Author
Owner

mentioned in issue #610

mentioned in issue #610
Author
Owner

marked this issue as related to #610

marked this issue as related to #610
Author
Owner

marked this issue as related to AlekSIS-App-Chronos#153

marked this issue as related to AlekSIS-App-Chronos#153
Author
Owner

mentioned in issue AlekSIS-App-Chronos#153

mentioned in issue AlekSIS-App-Chronos#153
Author
Owner

This requires a major re-design. Therefore, removing from %"2022.6 — "Cohn""

This requires a major re-design. Therefore, removing from %"2022.6 — "Cohn""
Member

Maybe discuss this issue soon, as we are currently in a major re-design phase.

Maybe discuss this issue soon, as we are currently in a major re-design phase.
Member

we want this

we want this
Member

mentioned in issue AlekSIS-App-Alsijil#253

mentioned in issue AlekSIS-App-Alsijil#253
Member

mentioned in issue AlekSIS-App-Alsijil#266

mentioned in issue AlekSIS-App-Alsijil#266
Member

How would this work technically: Each app can declare inside the index.js which collection the respective app defines, and which components it provides for specific collections. Vite/the bundler will somehow merge thes values and provide at a singular place (via the aleksis mixin maybe?).

Example: the core would define the collections "core-dashboard", "core-person-overview" and "core-group-overview", and alsijil would supply components for personal statistics (and at a later point one for group statistics as well)

This should work for any object type, so there could be a collection for components, but also for objects (e.g. extensible menus) or functions (e.g. extensible actions on a crud page)

How would this work technically: Each app can declare inside the index.js which collection the respective app defines, and which components it provides for specific collections. Vite/the bundler will somehow merge thes values and provide at a singular place (via the aleksis mixin maybe?). Example: the core would define the collections "core-dashboard", "core-person-overview" and "core-group-overview", and alsijil would supply components for personal statistics (and at a later point one for group statistics as well) This should work for any object type, so there could be a collection for components, but also for objects (e.g. extensible menus) or functions (e.g. extensible actions on a crud page)
Owner

assigned to @ZugBahnHof and unassigned @nik

assigned to @ZugBahnHof and unassigned @nik
Member
<script>
// Inside the index.js in the core
export const collections = [
    {
        name: "dashboard", // Auto-prefixed with the app label (?)
        type: Object, // Documentation purposes, maybe used for validation at a later point. Maybe add a validator func?
    }
]

// Inside the index.js in dashboard-feeds

export const collectionItems = {
    coreDashboard: [
        {
            name: "dashboardFeeds.rssFeedWidget",
            component: () => import("RSSFeedWidget.vue")
            shouldDisplay: (user, person, preferences) => {
                if (preferences.showDefaultDashboard) return true;
                if (user.isAdmin) return true;
                return false;
            }
        }
    ]
}

// Inside the frontend component file

import { coreDashboard } from "aleksis.collections"; // → how should the imports look?

export default {
  name: "DashboardComponent",
  mixins: { mixinThatGivesMeUserDetails },
  computed: {
    widgets() {
      // Is this really just an array or should be something different?
      return coreDashboard.filter(widget => widget.shouldDisplay(user, person, preferences));
    },
    widgetProps() {
      return {
        idk: "???",
        person,
        "???": "idk",
      }
    }
  },
};

</script>

<template>
    <div v-for="widget in widgets">
      <component :is="widget.component" v-bind="widgetProps" />
    </div>
</template>

How does this example usage look for you @hansegucker (this is purely fictional at this point)

I highlighted important things in the code for you.

I believe we also discussed something about other exported properties being merged, however then i wouldn't know how one would access them. Do you remember more?

```vue <script> // Inside the index.js in the core export const collections = [ { name: "dashboard", // Auto-prefixed with the app label (?) type: Object, // Documentation purposes, maybe used for validation at a later point. Maybe add a validator func? } ] // Inside the index.js in dashboard-feeds export const collectionItems = { coreDashboard: [ { name: "dashboardFeeds.rssFeedWidget", component: () => import("RSSFeedWidget.vue") shouldDisplay: (user, person, preferences) => { if (preferences.showDefaultDashboard) return true; if (user.isAdmin) return true; return false; } } ] } // Inside the frontend component file import { coreDashboard } from "aleksis.collections"; // → how should the imports look? export default { name: "DashboardComponent", mixins: { mixinThatGivesMeUserDetails }, computed: { widgets() { // Is this really just an array or should be something different? return coreDashboard.filter(widget => widget.shouldDisplay(user, person, preferences)); }, widgetProps() { return { idk: "???", person, "???": "idk", } } }, }; </script> <template> <div v-for="widget in widgets"> <component :is="widget.component" v-bind="widgetProps" /> </div> </template> ``` How does this example usage look for you @hansegucker (this is purely fictional at this point) I highlighted important things in the code for you. I believe we also discussed something about other exported properties being merged, however then i wouldn't know how one would access them. Do you remember more?
Owner

I think this looks very good.

I think this looks very good.
Member

ok

ok
Member

created branch 122-allow-injecting-widgets-into-all-object-views to address this issue

created branch [`122-allow-injecting-widgets-into-all-object-views`](/AlekSIS/official/AlekSIS-Core/-/compare/master...122-allow-injecting-widgets-into-all-object-views) to address this issue
Member

mentioned in merge request !3105

mentioned in merge request !3105
permcu commented 2024-05-14 12:36:19 +02:00 (Migrated from edugit.org)

mentioned in issue #1014

mentioned in issue #1014
permcu commented 2024-06-04 22:21:46 +02:00 (Migrated from edugit.org)

mentioned in issue #1024

mentioned in issue #1024
Owner

mentioned in issue AlekSIS#81

mentioned in issue AlekSIS#81
Owner

mentioned in issue AlekSIS/onboarding/AlekSIS-App-Maka#1

mentioned in issue AlekSIS/onboarding/AlekSIS-App-Maka#1
Owner

mentioned in commit 6fa761243e

mentioned in commit 6fa761243e3ba43d29e728d7f90f712592728723
Sign in to join this conversation.
No milestone
No project
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aleksis/AlekSIS-Core#122
No description provided.