disciple-tools-theme icon indicating copy to clipboard operation
disciple-tools-theme copied to clipboard

Tile visibility structure

Open corsacca opened this issue 2 years ago • 4 comments

Current structure:

$tiles['disciple_tools_plugin_starter_template'] = [
    'label' => __( 'Plugin Starter Template', 'disciple-tools-plugin-starter-template' ),
    'description' => __( 'This is a tile that is added by the plugin starter template.', 'disciple-tools-plugin-starter-template' ),
    'hidden' => false,
    'display_conditions' => [
        'visibility' => 'visible', //hidden, custom, visible
        'operator' => 'or', //and, or
        'conditions' => [
            'overall_status__active' => [ 'key' => 'overall_status', 'value' => 'active' ],
            'overall_status__paused' => [ 'key' => 'overall_status', 'value' => 'paused' ],
            'tags__tag1' => [ 'key' => 'tags', 'value' => 'tag1' ],
            'tags__tag'2 => [ 'key' => 'tags', 'value' => 'tag2' ]
        ],
    ],
];

Desired Structure:

$tiles['disciple_tools_plugin_starter_template'] = [
    'label' => __( 'Plugin Starter Template', 'disciple-tools-plugin-starter-template' ),
    'description' => __( 'This is a tile that is added by the plugin starter template.', 'disciple-tools-plugin-starter-template' ),
    'hidden' => false,
    'display_conditions' => [
        'visibility' => 'visible', //hidden, custom, visible
        'operator' => 'or', //and, or
        'conditions' => [
            'overall_status' => [ 'active', 'paused' ],
            'tags' = [ 'tag1', 'tag2' ],
        ]
    ],
];

Also add the ability to filter out:

'conditions' => [
    'overall_status' => [ '-closed'],
]

Might need a settings migration to change structure

corsacca avatar Mar 24 '23 10:03 corsacca

Also add restricting visibility by role

corsacca avatar May 20 '24 09:05 corsacca

If you have both role and post/record conditions, would it make sense to separate those a bit in the structure? Something like...

'conditions' => [
    'post' => [
        'overall_status' => [ '-closed' ],
    ],
    'user' => [
        'role' => [ 'dt_admin', 'dispatcher' ],
    ],
]

This might allow more flexibility for other types of conditions in the future. I don't know what those others would be, but it might be a bit better than making a special case for a condition with key role. Who knows if someone might one day put a role field on contacts and want a condition on that.

cairocoder01 avatar May 20 '24 09:05 cairocoder01

Yeah, that looks like a better structure I'll revise by previous comment. In D.T we focus more and the permission instead of a role. This way a new role could be given access too. So we might do this instead:

'user ' => [
  'permission' => [ 'see_all_contacts' ],
]

corsacca avatar May 20 '24 09:05 corsacca

Can we have both roles and permissions available? If I have two different roles for digital responders and field multipliers that have the same permissions, I still want each of them to view different fields. I have fields specific for online vs those applicable to face-to-face.

cairocoder01 avatar May 20 '24 09:05 cairocoder01