Skip to content

Commit

Permalink
Melhorias
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopaulichi committed Jan 18, 2018
1 parent 1f95be7 commit 5922566
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/softgrid.tpl.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/softgrid.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/softgrid.min.js

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion mock/app.js
Expand Up @@ -69,10 +69,12 @@ angular.module('todoApp', ['softgrid.directive','ngSanitize'])

vm.controles.progress = { item: function (item) { return item.progresso ;}, title: "Conclusão", class: function (item){ return 'progress-bar-success'}};

vm.controles.showAction = _showMenu;

//vm.controles.favorite = { title: "Favoritar", function: _editar, item: function(item){ return item.ativo }, width: 50, show: function(item){ return item.ativo === false;} };

vm.subgrid = {};
vm.subgrid.item = function (item) { return item.sub };
vm.subgrid.item = function (item) { return item };

vm.subgrid.cols = [
{title: "Nome", item: function(item){return item.nome}, edit: { item: "nome", function: _editar, width: "100%"}},
Expand All @@ -84,8 +86,30 @@ angular.module('todoApp', ['softgrid.directive','ngSanitize'])

vm.store = {enabled: true, id: "GRID1" }

vm.acoes = [
{title: "Editar", icon: "fa fa-info-circle", function: _teste, show: _showItemA },
{title: "Excluir", icon: "fa fa-wrench", function: _teste, show: _showItemB},
{title: "Bloquear", icon: "fa fa-calculator", function: _teste}
];


}

function _showMenu(item){

return item.progresso > 0
}

function _showItemA(item){
return item.progresso > 10 && item.progresso < 20
}

function _showItemB(item){
return item.progresso < 10;
}

function _showItemC(item){
return item.progresso > 90;
}

function _editar(item){
Expand Down
2 changes: 1 addition & 1 deletion mock/index.html
Expand Up @@ -45,7 +45,7 @@ <h1>Softgrid</h1>
<hr>
<div ng-controller="TodoListController as vm">

<softgrid cols="vm.colunas" data="vm.data" sg-controls="vm.controles" sg-menu="vm.menu" hide="vm.hide"> </softgrid>
<softgrid cols="vm.colunas" data="vm.data" actions="vm.acoes" sg-controls="vm.controles" sg-menu="vm.menu" hide="vm.hide"> </softgrid>

</div>

Expand Down
12 changes: 11 additions & 1 deletion src/softgrid.html
Expand Up @@ -172,6 +172,8 @@

<td ng-show="subgrid || actions.length > 0" style="text-align:center; width: {{larguraColunaAcoes}}px">

<div ng-show="sgControls.showAction ? sgControls.showAction(row) : true">

<!-- botão para exibir sub tabela -->
<button ng-show="subgrid" type="button" class="btn btn-default btn-sm btn-subgrid" ng-click="showSubGrid = showSubGrid ? false : true" style="float: left;">
<span class="fa fa-expand" ng-class="{'fa-compress': showSubGrid}"></span>
Expand All @@ -184,11 +186,19 @@
</button>

<ul class="dropdown-menu dropdown-menu-left">
<li ng-repeat="action in actions"><a ng-click="action.function(row)"><span class="{{action.icon}}"></span> {{action.title}}</a></li>

<li ng-repeat="action in actions" ng-show="action.show ? action.show(row) : true">

<a ng-click="action.function(row)"><span class="{{action.icon}}"></span> {{action.title}}</a>

</li>

</ul>

</div>

</div>

</td>

<!-- column to actions -->
Expand Down

0 comments on commit 5922566

Please sign in to comment.