[% site_config.title = c.loc('Administrators') -%]
[%
    helper.name = c.loc('Administrator');
    helper.identifier = 'administrator';
    helper.show_create_button = 1;
    helper.data = admins;
    helper.messages = messages;
    helper.dt_columns = admin_dt_columns;
    helper.length_change = 1;

    helper.close_target = close_target;
    helper.create_flag = create_flag;
    helper.edit_flag = edit_flag;
    helper.form_object = form;
    helper.ajax_uri = c.uri_for( c.controller.action_for('ajax') );

    IF !c.user.read_only;
        IF c.user.is_master && (c.user.roles ==  'admin' || c.user.roles == 'reseller');
            helper.dt_buttons = [
                { name = c.loc('Edit'), uri = "/administrator/'+full[\"id\"]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' },
                { name = c.loc('Delete'), uri = "/administrator/'+full[\"id\"]+'/delete", class = 'btn-small btn-secondary', icon = 'icon-trash', condition = 'full[\'login\'] != \'' _ special_admin_login _ '\'' },
                { name = c.loc('API key'), uri = "/administrator/'+full[\"id\"]+'/api_key", class = 'btn-small btn-info', icon = 'icon-lock', condition = 'full[\'login\'] != \'' _ special_admin_login _ '\' && full[\'id\'] == \'' _ c.user.id _ '\'' },
            ];

            helper.top_buttons = [
                { name = c.loc('Create Administrator'), uri = c.uri_for('/administrator/create'), icon = 'icon-star' },
            ];
        ELSE;
            helper.dt_buttons = [
                { name = c.loc('Edit'), uri = "/administrator/'+full[\"id\"]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit', condition = 'full[\'id\'] == \'' _ c.user.id _ '\'' },
                { name = c.loc('API key'), uri = "/administrator/'+full[\"id\"]+'/api_key", class = 'btn-small btn-info', icon = 'icon-lock', condition = 'full[\'id\'] == \'' _ c.user.id _ '\'' },
            ];
        END;
    END;

    PROCESS 'helpers/datatables.tt';

    IF api_modal_flag;
        PROCESS "helpers/modal.tt";
        modal_header(m.name = "API key");
        helper.form_object.render;
        modal_footer();
        modal_script(m.close_target = helper.close_target);
    END;
-%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]
