We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50658
    • 6 Posts
    I am developing a package/CMP that should allow for the following work flow:
    User is setting up a number of preset dashboards based on specific occupation role that has a number of application widgets associated with that role. The UIX should provide the user with a CMP that displays a grid with the following columns
    | role name | list of applications |
    | Customer Rep | App1, App21, App67 |

    my schema is as follow:
    <?xml version="1.0" encoding="utf-8"?>
    <model package="pscupresets" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
      <object class="DashboardRole" table="pscu_roles" extends="xPDOObject">
        <field key="id" dbtype="int" precision="11" phptype="integer" null="false" index="pk"  generated="native" />
        <field key="name" dbtype="text" phptype="string" null="true" />
        <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
          <column key="id" collation="A" null="false" />
        </index>
        <composite alias="applications" class="PresetApplication" local="id" foreign="roleId" cardinality="many" owner="local" />
      </object>
      <object class="PresetApplication" table="pscu_rolesPresets" extends="xPDOObject">
        <field key="id" dbtype="int" precision="11" phptype="integer" null="false" index="pk"  generated="native" />
        <field key="roleId" dbtype="int" precision="11" phptype="integer" null="true" />
        <field key="name" dbtype="text" phptype="string" null="true" />
        <field key="applicationId" dbtype="int" precision="11" phptype="integer" null="false" />
        <index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
          <column key="id" collation="A" null="false" />
        </index>
        <aggregate alias="roleOwner" class="DashboardRole" local="roleId" foreign="id" cardinality="one" owner="foreign" />
      </object>
    </model>
    


    I have not been able to figure out how I can add the form that allows to add multiple applications to a role. whenever I set up the the input TV type to modxdb I get a grid but it doesn't have an add item option and I am not really certain about the steps that I need to take to create the form fields for the applications_name and applications_applicationId so those can be used when adding the data.
    Question 1: how should I accomplish the above forms set up so when adding or editing a DashboardRole I have an option to add a list of applications to it?

    Question 2: Last I need to display in the grid a list of application names assigned to the role. what should I do to set up that if possible at all.

    this is the export of my config (excuse the mess)

    {
      "formtabs":[
        {
          "MIGX_id":3,
          "caption":"Role",
          "print_before_tabs":"0",
          "fields":[
            {
              "MIGX_id":8,
              "field":"name",
              "caption":"Role name",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":1
            },
            {
              "MIGX_id":9,
              "field":"applications",
              "caption":"Applications",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"migxdb",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":2
            },
            {
              "MIGX_id":10,
              "field":"applications_name",
              "caption":"Application Name",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":3
            },
            {
              "MIGX_id":11,
              "field":"applications_applicationId",
              "caption":"PSCU applicationId",
              "description":"",
              "description_is_code":"0",
              "inputTV":"",
              "inputTVtype":"",
              "validation":"",
              "configs":"",
              "restrictive_condition":"",
              "display":"",
              "sourceFrom":"config",
              "sources":"",
              "inputOptionValues":"",
              "default":"",
              "useDefaultIfEmpty":"0",
              "pos":4
            }
          ],
          "pos":1
        }
      ],
      "contextmenus":"update||duplicate||remove||movetotop_migx||movetotop_bottom",
      "actionbuttons":"addItem",
      "columnbuttons":"",
      "filters":"",
      "extended":{
        "migx_add":"Add dashboard role",
        "disable_add_item":"",
        "add_items_directly":"",
        "formcaption":"",
        "update_win_title":"",
        "win_id":"pscupresets",
        "maxRecords":"",
        "addNewItemAt":"bottom",
        "multiple_formtabs":"",
        "multiple_formtabs_label":"",
        "multiple_formtabs_field":"",
        "multiple_formtabs_optionstext":"",
        "multiple_formtabs_optionsvalue":"",
        "actionbuttonsperrow":4,
        "winbuttonslist":"",
        "extrahandlers":"",
        "filtersperrow":4,
        "packageName":"pscupresets",
        "classname":"DashboardRole",
        "task":"",
        "getlistsort":"",
        "getlistsortdir":"",
        "sortconfig":"",
        "gridpagesize":"",
        "use_custom_prefix":"0",
        "prefix":"",
        "grid":"",
        "gridload_mode":1,
        "check_resid":1,
        "check_resid_TV":"",
        "join_alias":"applications",
        "has_jointable":"yes",
        "getlistwhere":"",
        "joins":"",
        "hooksnippets":"",
        "cmpmaincaption":"Manage Dashboards",
        "cmptabcaption":"Dashboard Roles",
        "cmptabdescription":"Add\/edit dashboard role",
        "cmptabcontroller":"",
        "winbuttons":"",
        "onsubmitsuccess":"",
        "submitparams":""
      },
      "columns":[
        {
          "MIGX_id":1,
          "header":"Id",
          "dataIndex":"id",
          "width":"",
          "sortable":"false",
          "show_in_grid":"0",
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":"",
          "editor":""
        },
        {
          "MIGX_id":2,
          "header":"Role Name",
          "dataIndex":"name",
          "width":"",
          "sortable":true,
          "show_in_grid":1,
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":"",
          "editor":""
        },
        {
          "MIGX_id":3,
          "header":"Applications",
          "dataIndex":"applications",
          "width":"",
          "sortable":"false",
          "show_in_grid":1,
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":"",
          "editor":""
        }
      ]
    }
    [ed. note: eskarinna last edited this post 8 years, 10 months ago.]
      • 4172
      • 5,888 Posts
      Before we talk about the setup, lets talk about your xpdo - schema and your db-design

      1. There is missing the table for the applications itself
      2. I would suggest to extend xPDOSimpleObject
      3. In the connection-table, you need normally only two fields, if you don't need additional infos for each relation, like a order-position ore something like that.

      So it should look like that:

      <?xml version="1.0" encoding="utf-8"?>
      <model package="pscupresets" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
        <object class="pscuDashboardRole" table="pscu_roles" extends="xPDOSimpleObject">
          <field key="name" dbtype="text" phptype="string" null="true" />
          <composite alias="applications" class="PresetApplication" local="id" foreign="roleId" cardinality="many" owner="local" />
        </object>
        <object class="pscuPresetApplication" table="pscu_rolesPresets" extends="xPDOSimpleObject">
          <field key="roleId" dbtype="int" precision="11" phptype="integer" null="true" />
          <field key="applicationId" dbtype="int" precision="11" phptype="integer" null="false" />
          <aggregate alias="roleOwner" class="DashboardRole" local="roleId" foreign="id" cardinality="one" owner="foreign" />
          <aggregate alias="Application" class="" local="applicationId" foreign="id" cardinality="one" owner="foreign" />
        </object>
        <object class="pscuApplication" table="pscu_applications" extends="xPDOSimpleObject">
          <field key="name" dbtype="text" phptype="string" null="true" />
          <composite alias="Roles" class="PresetApplication" local="id" foreign="applicationId" cardinality="many" owner="local" />
        </object>
      </model>


      Does this look right to you, for what you are after?

      The setup depends a bit on how many applications there are and how many applications each Role can have.
      If this are not that many, you could simply have a lisbox-multiple to set them and have hook-snippets for update and get the formfield.

      If this are a lot, you can setup a nested (searchable) grid with a checkbox-column to set the relations.

      Let me know, which setup you would prefer.



        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 50658
        • 6 Posts
        The applications exist as resources under modx resource tree and also in an external system from which we retrieve data through an API. The applicationId is actually the modx resource Id and the name is just for the help of the admin so they have a way to recognize what application is corresponding to the Id

        As far as number of total applications there are hundreds but only 5-10 will be added as presets for a role. [ed. note: eskarinna last edited this post 8 years, 10 months ago.]
          • 4172
          • 5,888 Posts
          OK.
          Then listbox-multiple or grid - solution to select the application-resources connected to the roles?
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 50658
            • 6 Posts
            I was thinking two text boxes one for name and one for Id and added to a grid that is displayed on the form tab for role.
              • 50658
              • 6 Posts
              Quote from: Bruno17 at Jun 26, 2015, 03:25 PM
              OK.
              Then listbox-multiple or grid - solution to select the application-resources connected to the roles?

              I just wanted to check if my reply above makes sense smiley
                • 4172
                • 5,888 Posts
                what do you think, how many applications this will be?
                If not to much, a listbox-multiple and some hook-snippets for 'aftersave' to write the datas and 'aftergetfields' to read the datas to the listbox-field, should do it
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 50658
                  • 6 Posts
                  Quote from: Bruno17 at Jun 30, 2015, 05:15 AM
                  what do you think, how many applications this will be?
                  If not to much, a listbox-multiple and some hook-snippets for 'aftersave' to write the datas and 'aftergetfields' to read the datas to the listbox-field, should do it

                  300+ that's why I rather have a text box to supply the Application Id and Name since the list of applications will change as the customer provides more services
                    • 50658
                    • 6 Posts
                    Can you please help me I have a deadline and I really need to get that setup this week.

                    Quote from: Bruno17 at Jun 30, 2015, 05:15 AM
                    what do you think, how many applications this will be?
                    If not to much, a listbox-multiple and some hook-snippets for 'aftersave' to write the datas and 'aftergetfields' to read the datas to the listbox-field, should do it
                      • 4172
                      • 5,888 Posts
                      I'm about to put the pieces together, for what you will need.
                      Will be a grid with the application-resources, whith a checkbox-column, where they can select the applications for the current role.
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!