Last active
August 29, 2015 14:14
-
-
Save jamlfy/d30107b96662abab693a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Tu modelo... bla... bla.. | |
| module.exports = { | |
| attributes: { | |
| // Los Atributos.... | |
| }, | |
| damePlantas: function (){ | |
| try { | |
| var pl = JSON.parse(this.plantas); | |
| return pl; | |
| }catch(e){ | |
| // e Es el error generado | |
| return _.isObject(this.plantas) ? this.plantas : {}; | |
| } | |
| }, | |
| // Uso | |
| user.damePlantas() --> Objeto |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <h3>Gestión de usuarios</h3> | |
| <table class='table'> | |
| <tr> | |
| <th></th> | |
| <th>ID</th> | |
| <th>Nombre</th> | |
| <th>Email</th> | |
| <th>Plantas</th> | |
| <th></th> | |
| <th></th> | |
| <th></th> | |
| </tr> | |
| <% _.each(users, function(user) { %> | |
| <tr data-id="<%= user.id %>" data-model="user"> | |
| <% if (user.online) { %> | |
| <td><img src="/images/icon-online.png"></td> | |
| <% } else { %> | |
| <td> <img src="/images/icon-offline.png"></td> | |
| <% } %> | |
| <td><%= user.id %></td> | |
| <td><%= user.name %></td> | |
| <td><%= user.email %></td> | |
| <td> | |
| <% if (user.plantas){ %> | |
| <% _.each(JSON.parse(user.plantas), function(planta_name, planta_id) { | |
| <div><%= sails.config.mon.plantas[planta_id.toUpperCase()] %></div> | |
| <% }); %> | |
| <% } %> | |
| </td> | |
| <% if (user.admin) { %> | |
| <td><img src="/images/admin.png"></td> | |
| <% } else { %> | |
| <td> <img src="/images/pawn.png"></td> | |
| <% } %> | |
| <td><a href="/user/show/<%= user.id %>" class="btn btn-sm btn-primary">Ver</a></td> | |
| <td><a href="/user/edit/<%= user.id %>" class="btn btn-sm btn-warning">Editar</a></td> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment