<commit_before>Ext.define('Alegra.view.contact.Grid' ,{
  extend: 'Ext.grid.Panel',
  alias: 'widget.contactGrid',
  requires: ['Ext.toolbar.Paging'],
  iconCls: 'icon-grid',
  title: 'Contactos',
  store: 'Contacts',
  columns: [{
    header: 'Nombre',
    width: 299,
    flex: 1,
    dataIndex: 'name',
    menuDisabled: true,
  }, {
    header: 'Identificación',
    width: 177,
    flex: 1,
    dataIndex: 'identification',
    menuDisabled: true,
  }, {
    header: 'Teléfono 1',
    width: 177,
    flex: 1,
    dataIndex: 'phonePrimary',
    menuDisabled: true,
  }, {
    header: 'Observaciones',
    width: 177,
    flex: 1,
    dataIndex: 'observations',
    menuDisabled: true,
  }],
  initComponent: function() {
    this.dockedItems = [{
      xtype: 'toolbar',
      items: [{
        iconCls: 'icon-save',
        text: 'Agregar',
        action: 'add'
      }, {
        iconCls: 'icon-delete',
        text: 'Eliminar',<commit_msg>feat: Agrega funciones al Grid<commit_after>let sm = Ext.create('Ext.selection.CheckboxModel');

Ext.define('Alegra.view.contact.Grid', {
  extend: 'Ext.grid.Panel',
  alias: 'widget.contactGrid',
  requires: ['Ext.toolbar.Paging'],
  iconCls: 'icon-user',
  title: 'Contactos',
  selModel: sm,
  store: 'Contacts',
  stripeRows: true,
  columnLines: true,
  columns: [{
    header: 'Nombre',
    width: 299,
    flex: 1,
    dataIndex: 'name',
    align: 'center',
    menuDisabled: true,
  }, {
    header: 'Identificación',
    width: 177,
    flex: 1,
    dataIndex: 'identification',
    align: 'center',
    menuDisabled: true,
  }, {
    header: 'Teléfono 1',
    width: 177,
    flex: 1,
    dataIndex: 'phonePrimary',
    align: 'center',
    menuDisabled: true,
  }, {
    header: 'Observaciones',
    width: 177,
    flex: 1,
    dataIndex: 'observations',
    align: 'center',
    menuDisabled: true,
  }, {
    xtype: 'actioncolumn',
    width: 50,
    text: 'Acciones',
    align: 'center',
    flex: 1,
    menuDisabled: true,
    items: [
      {
        icon   : 'https://cdn1.alegra.com/images/icons/zoom.png',
        tooltip: 'Visualizar',
        handler: function(grid, rowIndex, colIndex) {
          var rec = grid.getStore().getAt(rowIndex);
        },
      }, {
        icon   : 'https://cdn1.alegra.com/images/icons/page_edit.png',
        tooltip: 'Editar',
        handler: function(grid, rowIndex, colIndex) {
          var rec = grid.getStore().getAt(rowIndex);
          let formEdit = Ext.create('Alegra.view.contact.Form').show();
          // Si se edita un record.
          if (rec.stores != null) {
            formEdit.down('form').loadRecord(rec);
          }
        },
      }, {
        icon   : 'https://cdn1.alegra.com/images/icons/delete.png',
        tooltip: 'Editar',
        handler: function(grid, rowIndex, colIndex) {
          let rec = grid.getStore().getAt(rowIndex);
          let store = grid.getStore();
      		Ext.Msg.show({
      			title: 'Eliminar cliente',
      			msg: '¿Estás seguro de que deseas eliminar el cliente? Esta operación no se puede deshacer',
      			buttons: Ext.Msg.YESNOCANCEL,
      			icon: Ext.MessageBox.QUESTION,
    				scope: this,
      			width: 600,
      			fn: function(btn) {
      				if (btn == 'yes') {
                let myMask = new Ext.LoadMask(Ext.getBody(), { msg:"Por favor, espere..." });
    						myMask.show();
      					store.remove(rec);
      					store.sync({
      						success: function (batch, action) {
      							myMask.hide();
      							// Cargar de nuevo el store.
      							store.load();
      							let reader = batch.proxy.getReader();
      							Ext.Msg.alert('Success', reader.jsonData.message );
      						},
      						failure: function (batch, action) {
      							myMask.hide();
      							let reader = batch.proxy.getReader();
      							Ext.Msg.alert('Failed', reader.jsonData ? reader.jsonData.message : 'No response');
      						},
    							scope: this,
      					});
      				}
      			}
      		});
        },
      },
    ],
  }],
  initComponent: function() {
    this.dockedItems = [{
      xtype: 'toolbar',
      items: [{
        iconCls: 'icon-save',
        text: 'Agregar',
        action: 'add'
      }, {
        iconCls: 'icon-delete',
        text: 'Eliminar',
{'fraction_non_alphanumeric': 0.151981351981352, 'fraction_numerical': 0.010023310023310023, 'mean_word_length': 2.0325088339222614, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '904300', 'n_tokens_mistral': 1580, 'n_tokens_neox': 1441, 'n_words': 296}