Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createInputs(arrInputs){
- //(_global.debug) ? console.log('AQUI!!!<br><br> ' + JSON.stringify(arrInputs)) : '' ;
- var strHtml = '';
- var acts = {
- form: false,
- formGroup: false,
- table: false,
- nav: false,
- collapse: false,
- div: false
- };
- if(item.obj == 'table'){
- strHtml += (acts['div']) ? '</div>' : '' ;
- strHtml += (acts['formGroup']) ? '</div>' : '' ;
- strHtml += (acts['table']) ? '</table>' : '' ;
- item.id = (item.id === undefined || item.id === null) ? '' : item.id ;
- item.size = (item.size === undefined || item.size === null) ? '' : item.size ;
- item.preSize = (item.preSize === undefined || item.preSize === null) ? '' : item.preSize ;
- item.autocLose = (item.autocLose === undefined || item.autocLose === null) ? false : item.autocLose ;
- item.columns = (item.columns === undefined || item.columns === null) ? [] : item.columns ;
- item.remove = (item.remove === undefined || item.remove === null) ? '' : item.remove ;
- item.order = (item.order === undefined || item.order === null) ? '' : item.order ;
- item.idadd = (item.idadd === undefined || item.idadd === null) ? '' : item.idadd ;
- item.textadd = (item.textadd === undefined || item.textadd === null) ? '' : item.textadd ;
- item.classadd = (item.classadd === undefined || item.classadd === null) ? '' : item.classadd ;
- item.size = (item.preSize != '') ? (item.size + '-' + item.preSize) : item.size ;
- strHtml += createTable(item.id, item.size, item.autocLose, item.columns, item.remove, item.order, item.idadd, item.textadd, item.classadd);
- acts['table'] = true;
- }
- }
- function createTable(id, size, autoClose, columns, remove, order, idAdd, textAdd, classadd){
- var k = 0;
- var auxColumns = '';
- var auxHtml = '';
- var auxHtmlHide = '';
- var td = false;
- for(var k=0; k < columns.length; k++){
- if(columns[k].obj !== undefined){
- if(columns[k].type == 'hidden'){
- auxHtmlHide += window[_global.objVars.mints].custom.createInputs( [ columns[k] ] );
- td = false;
- } else {
- var textColum = (columns[k].columname === undefined) ? '' : columns[k].columname ;
- var columsize = (columns[k].columsize === undefined) ? '12' : columns[k].columsize ;
- var auxSize = this.size( columsize );
- auxColumns += '<th class="tableColumn">' + textColum + '</th>'
- auxHtml += (td) ? '</td>' : '' ;
- auxHtml += '<td class="fs-v-align-middle ' + auxSize + '">';
- td = true;
- auxHtml += window[_global.objVars.mints].custom.createInputs( [ columns[k] ] );
- }
- }
- }
- var htmlFirstColum = '<td class="bpm-mobile-trash-column"><div class="hidden-inputs">' + auxHtmlHide + '</div>';
- var auxHtmlOrder = '';
- if(order === true){
- auxHtmlOrder = '' +
- '<div class="col-lg-2 col-md-2 col-sm-2 col-xs-12" style="padding-top:7px">' +
- ' <label name="contador" id="contador" class="control-label" value="">0</label>' +
- '</div>';
- }
- htmlFirstColum += auxHtmlOrder;
- var auxHtmlRemove = '';
- if(remove !== undefined && remove !== ''){
- auxHtmlRemove += '' +
- '<div class="col-lg-8 col-md-8 col-sm-8 col-xs-12" >' +
- '<span class="fluig-style-guide fs-display-block fs-xs-space">' +
- ' <i class="fluigicon fluigicon-trash fluigicon-md" onclick="Javascript:' + remove + '" style="cursor:pointer"></i>'+
- '</span>'+
- '</div>';
- }
- htmlFirstColum += auxHtmlRemove;
- htmlFirstColum += '</td>';
- var htmlLastColum = '';
- if(order === true){
- auxColumns = '' +
- '<th >' +
- ' <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">Nº</div>' +
- ' <div class="col-lg-10 col-md-10 col-sm-10 col-xs-12"> </div>' +
- '</th>' + auxColumns;
- } else {
- auxColumns = '<th></th>' + auxColumns;
- }
- auxHtml = htmlFirstColum + auxHtml + htmlLastColum;
- //auxHtml += window[_global.objVars.mints].custom.createInputs( columns );
- //console.log(auxHtml);
- var aux = '' +
- // '<div class="form-field" data-type="tabledetail" data-show-properties="" data-field-name="' + id + '">' +
- ' <div class="form-input">' +
- ' <div class="table-responsive">' +
- ' <table tablename="' + id + '" id="' + id + '" class="table table-condensed table-hover" onRemoveRow="' + remove + '" noAddButton="false" noDeleteButton="true" noOrder="true">' +
- ' <thead>' +
- ' <tr class="tableHeadRow" >' +
- ' ' + auxColumns +
- ' </tr>' +
- ' </thead>' +
- ' <tbody>' +
- ' <tr class="tableBodyRow" data-order="0" style="display:none;" >' +
- ' ' + auxHtml +
- ' </tr>' +
- ' </tbody>' +
- ' </table>' +
- ' </div>';
- if((idAdd != '') && (idAdd !== undefined)){
- aux += '' + this.button(idAdd, textAdd, '12', '', '', '', 'btn btn-default form-control ' + classadd, true, true);
- }
- aux += '' +
- ' </div>';
- // '</div>';
- size = (size !== undefined && size !== '') ? this.size( size ) : '' ;
- aux = (this.div('', size, false, 'tabledetail', ' data-show-properties="" data-field-name="' + id + '" ', 'form-field') + aux + '</div>');
- return aux;
- }
- var props = {
- target: 'divApp',
- models: ['LISTA_FUNCIONARIOS'],
- id: {
- div: {
- listTeachers: 'divListaFuncionarios',
- msg: 'divMsgListaFuncionarios',
- alert: 'divMsgAlertaListaFuncionarios'
- },
- panel: {
- prefixHeading: 'Heading',
- prefixBody: 'Body',
- teachers: 'panelListaFuncionarios',
- cadastre: 'panelCadastro',
- address: 'panelEndereco'
- },
- table: {
- teachers: 'tableFuncionarios',
- },
- button:{
- editTeacher: 'submitEditaFuncionario',
- newTeacher: 'submitNovoFuncionario',
- submit:{
- top: 'submitTop',
- bottom: 'submitBottom'
- }
- },
- input: {
- idJoin: 'idVinculo',
- codPerson: 'codVinculoPessoa',
- codSchool: 'codVinculoEscola',
- name: 'txtNome',
- cpf: 'numCpf',
- email: 'txtEmail',
- role: 'txtCargo',
- },
- select: {
- role: 'selCargo',
- active: 'selCargoAtivo'
- },
- zoom: {
- }
- },
- link: {
- defaul: '#'
- },
- text: {
- msgTitle: 'Funcionario.',
- msg: '...',
- alert: '...',
- edit: 'Editar',
- newTeacher: 'Novo Funcionario',
- panelTeachers: 'Funcionarios Vinculados',
- }
- }
- function populateTable(){
- var table = $('#' + idTarget).find('table')
- var tableRow = table.find('tbody tr[data-order=0]');
- var auxHtml = myFuns.custom.createInputs( columns );
- var dp_Funcionarios = fnConsultaParceiros(codCfo, codPessoa, cargo);
- var n = 1;
- if(DatasetPublic.validateReturn(dp_Funcionarios)){
- if(dp_Funcionarios.rowsCount > 0){
- for(var i=0; i < dp_Funcionarios.rowsCount; i++){
- if(retiraCargos.toLowerCase().indexOf(',' + dp_Funcionarios.values[i]['CARGO'].toLowerCase() + ',') == -1){
- //var row = wdkAddChild(ListaFuncionarios.props.id.table.teachers);
- var auxRow = tableRow.clone(false, false).attr('data-order', n);
- auxRow.find('[id!=_]').each(function(){
- var id = $(this).attr('id');
- (id == 'contador') ? $(this).html( n ) : '';
- if(id !== undefined){
- $(this).attr('id', id + '___' + n);
- }
- });
- auxRow.show();
- for (var idModel in dp_Funcionarios.values[i]) {
- var value = dp_Funcionarios.values[i][idModel];
- idModel = ((idModel.indexOf('VINCULO_') == -1) ? 'VINCULO_' : '' ) + idModel
- var item = auxRow.find('[data-rel-value=' + idModel + ']');
- item.val( '' );
- item.val( value );
- }
- table.find('tbody').append(auxRow);
- // Bloqueia cargos utilizados pelo sistema educacional
- if(bloqueiaCargos.toLowerCase().indexOf(',' + dp_Funcionarios.values[i]['CARGO'].toLowerCase() + ',') != -1){
- $('#' + ListaFuncionarios.props.id.button.editTeacher + '___' + n).attr('disabled', true).addClass('btn-primary');
- }
- n++;
- }
- }
- } else {
- msgErro = 'Não foi encontrado Funcionarios vinculados!';
- }
- } else {
- msgErro = 'Não foi possível encontrar Funcionarios vinculados para a escola selecionada!';
- }
- }
- var itens = new Array();
- var ids = props.id;
- itens = [
- {obj: 'table',
- id: ids.table.teachers,
- idadd: ids.button.newTeacher,
- textadd: this.props.text.newTeacher,
- classadd:'btn-success',
- remove: '', //'fnWdkRemoveChild(this)',
- order: true,
- columns: [
- {id: ids.input.idJoin, obj: 'input', type: 'hidden', value: '', relValue: 'VINCULO_IDVINCULO', size: '', required: false, readonly: true, text: '', columname: '', columsize: '0', div: false },
- {id: ids.input.codPerson, obj: 'input', type: 'hidden', value: '', relValue: 'VINCULO_CODPESSOA', size: '', required: true, readonly: true, text: '', columname: '', columsize: '0', div: false },
- {id: ids.input.codSchool, obj: 'input', type: 'hidden', value: '', relValue: 'VINCULO_CODCFO', size: '', required: false, readonly: true, text: '', columname: '', columsize: '0', div: false },
- {id: ids.input.name, obj: 'input', type: 'text', value: '', relValue: 'VINCULO_NOME_PESSOA',size: '', required: true, readonly: true, text: '', columname: 'Funcionario', columsize: '4', div: true, maxlength: '100' },
- {id: ids.input.cpf, obj: 'input', type: 'text', value: '', relValue: 'VINCULO_CPF', size: '', required: true, readonly: true, text: '', columname: 'CPF', columsize: '2', div: true, maxlength: '20', mask: '999.999.999-99', placeholder: '___.___.___-__', addclass: 'cpf' },
- {id: ids.input.email, obj: 'input', type: 'email', value: '', relValue: 'VINCULO_EMAIL', size: '', required: true, readonly: true, text: '', columname: 'E-mail', columsize: '2', div: true, maxlength: '60', addclass: 'email' },
- {id: ids.select.role, obj: 'select', type: 'text', value: '', relValue: 'VINCULO_CARGO', size: '', required: true, readonly: true, text: '', columname: 'Cargo', columsize: '2', div: true, options: window[_global.objVars.data].modelItens.CARGOS() },
- {id: ids.select.active, obj: 'select', type: 'text', value: '1', relValue: 'VINCULO_ATIVO', size: '', required: true, readonly: true, text: '', columname: 'Ativo', columsize: '1', div: true, options: window[_global.objVars.data].modelItens.ATIVO },
- {id: ids.button.editTeacher,obj: 'button', type: 'text', value: '', relValue: 'VINCULO_CODPESSOA', size: '12', required: false, readonly: false, text: 'Editar', columname: '', columsize: '1', div: false }
- ]
- },
- // {id: ids.button.newTeacher, obj: 'button', type: 'text', value: '-1', size: '12', text: this.props.text.newTeacher, div: true, addclass: 'btn-success' }
- ];
- // chama funções
- createInputs(itens);
- populateTable()
Add Comment
Please, Sign In to add comment