Commit 406838cd authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Refonte de la page de gestion des privilèges

parent f2c676d5
Loading
Loading
Loading
Loading
+2
Changes for module/Application/src/Entity/Db/Role.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ class Role implements HistoriqueAwareInterface, RoleInterface
{
    use HistoriqueAwareTrait;

    const ADMINISTRATEUR = 'administrateur';

    /**
     * @var integer
     */
+14 −31
Changes for module/Application/view/application/droits/privileges.phtml: 14 added lines, 31 removed lines.
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@
 * @var $this       \Application\View\Renderer\PhpRenderer
 * @var $privileges UnicaenAuth\Entity\Db\Privilege[]
 * @var $roles      Application\Entity\Db\Role[]
 * @var $filters    array
 */

?>
@@ -12,52 +11,36 @@
<table class="droits-tbl table table-bordered table-condensed table-extra-condensed table-header-rotated">
    <thead>
    <tr>
        <th class="menu"><a class="btn btn-default show-all">Supprimer les
                filtres</a></th>
        <th class="menu"></th>
        <?php foreach ($roles as $role): ?>
            <th class="rotate-45 role" data-role="<?= $role->getId() ?>" title="<?= $role; ?>">
                <div><span><a><?= $role; ?></a></span></div>
            <th class="rotate-45 role" data-role="<?= $role->getId() ?>">
                <div title="<?= $role; ?>"><span><a><?= $role; ?></a></span></div>
            </th>
        <?php endforeach; ?>
        <?php if (!empty($roles)): ?>
            <th class="separator rotate-45">&nbsp;</th>
        <?php endif; ?>
    </tr>
    <tr>
        <th>Privilèges</th>
        <?php if (!empty($roles)): ?>
            <th class="roles" colspan="<?= count($roles); ?>"><a class="roles">Rôles (personnel)</a></th>
        <?php endif; ?>
        <?php if (!empty($roles)): ?>
            <th class="separator">&nbsp;</th>
        <?php endif; ?>
        <th style="border:none;min-width:166px">&nbsp;</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <th class="categorie" colspan="<?= 2 + count($roles); ?>">
            <select class="categorie selectpicker" data-live-search="true" data-width="auto">
                <option value="">Veuillez choisir une catégorie de privilèges ...</option>
                <?php foreach ($privileges as $cat): ?>
        <tr class="categorie" data-categorie="<?= $cat['categorie']->getCode() ?>">
            <th class="categorie">&nbsp;</th>
            <th class="categorie" colspan="<?= 1 + count($roles); ?>">
                <a class="categorie"
                   data-categorie="<?= $cat['categorie']->getCode() ?>"><?= $cat['categorie'] ?></a>
                    <option value="<?= $cat['categorie']->getCode() ?>"><?= $cat['categorie'] ?></option>
                <?php endforeach; ?>
            </select>
        </th>
    </tr>
    <?php foreach ($privileges as $cat): ?>
        <?php foreach ($cat['privileges'] as $privilege): ?>
            <tr class="categorie" data-categorie="<?= $cat['categorie']->getCode() ?>">
            <tr class="categorie" data-categorie="<?= $cat['categorie']->getCode() ?>" style="display: none">
                <th class="privilege"><?= $privilege ?></th>
                <?php
                foreach ($roles as $role): ?>
                    <td class="modifier role" data-role="<?= $role->getId() ?>"
                        data-privilege="<?= $privilege->getId() ?>"
                        title="Rôle : <?= $role->getLibelle() ?>"
                    >
                    <td class="modifier role" data-role="<?= $role->getId() ?>" data-privilege="<?= $privilege->getId() ?>">
                        <?= $this->partial('/application/droits/partial/tbl-link', compact('role', 'privilege')) ?>
                    </td>
                <?php endforeach; ?>
                <?php if (!empty($roles)): ?>
                    <th class="separator ">&nbsp;</th>
                <?php endif; ?>

            </tr>
        <?php endforeach; ?>
    <?php endforeach; ?>
+27 −2
Changes for public/css/droits.css: 27 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -17,11 +17,36 @@ ul.privileges-form li label {
    width: 200px;
}

.droits_tbl th.role {
    width: 15px;
}

.droits_tbl td.role {
    width: 15px;
}

.droits-tbl td span.refuse {
.droits-tbl td i.refuse {
    opacity: 0.5;
}

.droits-tbl th.categorie {
    padding-top: 10pt;
    font-size: 16pt;
    font-family: "Open Sans",Helvetica,Arial,sans-serif;
    font-weight: 200;
}

.droits-tbl {
    border-left: none;
    border-right: none;
    border-bottom: none;
}

.droits-tbl thead tr th div {
    border-bottom: 1px solid #ddd;
}


.selected {
    background-color:#FCF8E3;
    background-color:#FCF8E3 !important;
}
 No newline at end of file
+17 −93
Changes for public/js/droits.js: 17 added lines, 93 removed lines.
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ $.widget("ose.droitsTbl", {
        td.html("<div class=\"loading\">&nbsp;</div>");
        td.load(Url('droits/privileges/modifier'), {
            role: td.data("role"),
            statut: td.data("statut"),
            privilege: td.data("privilege"),
            action: action
        }, function ()
@@ -23,33 +22,28 @@ $.widget("ose.droitsTbl", {
    },



    showOnlyCategorie: function (categorie)
    showHideCategorie: function (categorie)
    {
        this.element.find('tr.categorie[data-categorie!="' + categorie + '"]').hide();
        this.element.find('tr.categorie[data-categorie="' + categorie + '"]').each(function () {

            if ($(this).is(':visible')) {
                $(this).hide();
            } else {
                $(this).show();
            }
        });
    },



    showAll: function ()
    showCategorie: function (categorie)
    {
        this.element.find('tr.categorie').show();

        this.element.find('th.role').show();
        this.element.find('td.role').show();

        this.element.find('th.statut').show();
        this.element.find('td.statut').show();

        this.element.find('th.roles').attr('colspan', this.element.find('th.role:visible').length).show();
        this.element.find('th.statuts').attr('colspan', this.element.find('th.statut:visible').length).show();
        this.showHideSeparator();

        this.updateFirsts();
        console.log(categorie);
        this.element.find('tr.categorie[data-categorie!="' + categorie + '"]').hide();
        this.element.find('tr.categorie[data-categorie="' + categorie + '"]').show();
    },



    hideRole: function (roleId)
    {
        this.element.find('th.role[data-role="' + roleId + '"]').hide();
@@ -62,67 +56,16 @@ $.widget("ose.droitsTbl", {
            this.element.find('th.roles').hide();
        }

        this.showHideSeparator();
        this.updateFirsts();
    },



    hideRoles: function ()
    {
        this.element.find('th.role').hide();
        this.element.find('td.role').hide();
        this.element.find('th.roles').hide();
        this.showHideSeparator();
    },



    hideStatut: function (statutId)
    {
        this.element.find('th.statut[data-statut="' + statutId + '"]').hide();
        this.element.find('td.statut[data-statut="' + statutId + '"]').hide();

        var statutsCount = this.element.find('th.statut:visible').length;
        if (statutsCount > 0) {
            this.element.find('th.statuts').attr('colspan', statutsCount).show();
        } else {
            this.element.find('th.statuts').hide();
        }
        this.showHideSeparator();
        this.updateFirsts();
    },



    hideStatuts: function ()
    {
        this.element.find('th.statut').hide();
        this.element.find('td.statut').hide();
        this.element.find('th.statuts').hide();
        this.showHideSeparator();
    },



    showHideSeparator: function ()
    {
        if (this.element.find('th.roles:visible').length == 0 || this.element.find('th.statuts:visible').length == 0) {
            this.element.find('.separator').hide();
        } else {
            this.element.find('.separator').show();
        }
    },



    updateFirsts: function ()
    {
        this.element.find('th.role.first').removeClass('first');
        this.element.find('th.statut.first').removeClass('first');

        this.element.find('th.role:visible:first').addClass('first');
        this.element.find('th.statut:visible:first').addClass('first');
    },


@@ -153,7 +96,7 @@ $.widget("ose.droitsTbl", {

        this.element.find('a.categorie').click(function ()
        {
            that.showOnlyCategorie($(this).data('categorie'));
            that.showHideCategorie($(this).data('categorie'));
        });

        this.element.find('th.role a').click(function ()
@@ -162,31 +105,15 @@ $.widget("ose.droitsTbl", {
            that.hideRole(roleId);
        });

        this.element.find('th.statut a').click(function ()
        {
            var statutId = $(this).parents('.statut').data('statut');
            that.hideStatut(statutId);
        });

        this.element.find('a.roles').click(function ()
        {
            that.hideStatuts();
        });

        this.element.find('a.statuts').click(function ()
        {
            that.hideRoles();
        this.element.find('select.categorie').change(function () {
            that.showCategorie($(this).val());
        });

        this.element.find('.modifier').on('mouseover mouseout', function ()
        {
            if ($(this).data('statut')){
                var id = $(this).data('statut');
                var selector = 'statut';
            }else{

            var id = $(this).data('role');
            var selector = 'role';
            }

            that.element.find('.selected').removeClass('selected');

@@ -197,8 +124,6 @@ $.widget("ose.droitsTbl", {
            that.element.find('th.' + selector + '[data-' + selector + '="' + id + '"] div').toggleClass('selected');
        });

        this.element.find('a.show-all').click(function () { that.showAll();});

        this.updateFirsts();
    }
});
@@ -207,7 +132,6 @@ $.widget("ose.droitsTbl", {




/**
 *
 * @constructor