Commit f3e5fefd authored by D’jalmar Gutierrez Titirico's avatar D’jalmar Gutierrez Titirico 🚲

Merge remote-tracking branch 'origin/iss32-editar-postulantes-cargo' into...

Merge remote-tracking branch 'origin/iss32-editar-postulantes-cargo' into iss32-editar-postulantes-cargo

Conflicts:
	client/app/postulantes/editar/postulantes.editar.controller.js

Se refactorizaron los metodos para manejo de los tags
	modified:   client/app/postulantes/editar/postulantes.editar.controller.js
parents 2824c456 d3d91a15
<div class="row">
<h2 class="sub-header">Cargos</h2>
<button class="btn btn-default" ng-click="vm.crear()">Crear Cargo</button>
<div class="table-responsive">
<table class="table table-striped">
<thead>
......
tags-input .tags .tag-item {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
display: inline-block;
white-space: nowrap;
margin: -1px 5px 5px 0;
height: 22px;
vertical-align: top;
cursor: default;
color: #767676;
background-color: #fff;
border-color: #ccc;
}
......@@ -2,7 +2,7 @@
(()=> {
class PostulanteEditarController {
constructor($stateParams, postulanteService, datoPostulanteService, tipoDatoService, $uibModal, Modal) {
constructor($stateParams, postulanteService, datoPostulanteService, tipoDatoService, $uibModal, Modal, tagService, tagPostulanteService) {
this.errores = {}; // lista de errores
this.postulanteEnviado = false; // se refiere a si se intento enviar el formulario del postulante
this.Modal = Modal;
......@@ -10,14 +10,13 @@
this.service = postulanteService;
this.datoPostulanteService = datoPostulanteService;
this.tipoDatoService = tipoDatoService;
this.tagService = tagService;
this.tagPostulanteService = tagPostulanteService;
this.id = $stateParams.postulanteId;
this.tags = [];
this.service.getPostulante(this.id).then(postulante=> {
console.log(postulante);
this.postulante = postulante;
this.tags = [];
this.postulante.Tags.forEach(tag=> {
this.tags.push({text: tag.nombre})
})
console.log(postulante);
});
}
......@@ -99,7 +98,7 @@
controller: 'PostulantesEditarModalCtrl',
controllerAs: 'vm',
resolve: {
parametro: {postulante: this.postulante, cargo:cargo}
parametro: {postulante: this.postulante, cargo: cargo}
}
})
}
......@@ -114,6 +113,32 @@
}
})
}
autoCompletarTags(query) {
console.log(this.tags)
if (this.tags.length == 0) {
this.tagService.getTags(1, 100).then(tags=> {
this.tags = tags;
return this.tags.rows.filter(x=>x.includes(query));
})
}
else return this.tags.rows.filter(x=>x.nombre.includes(query));
}
adicionarTag(tag) {
if (tag._id) {
this.tagPostulanteService.crearTagPostulante({fk_tag: tag._id, fk_postulante: this.id});
}
else {
this.tagService.crearTag(tag).then(tag=> {
this.tagPostulanteService.crearTagPostulante({fk_tag: tag._id, fk_postulante: this.id});
})
}
}
quitarTag(tag) {
this.tagPostulanteService.eliminarTagPostulante(tag.TagPostulante._id);
}
}
angular.module('moduloPersonalApp')
.controller('PostulantesEditarCtrl', PostulanteEditarController);
......
......@@ -95,17 +95,10 @@
</uib-accordion-group>
<uib-accordion-group heading="Tags" class="panel-primary" is-open="true">
<div class="col-md-10">
<form class="form" name="form" ng-submit="vm.editar(form)" novalidate>
<tags-input ng-model="vm.tags">
<!--<auto-complete source="vm.loadTags($query)"></auto-complete>-->
<tags-input ng-model="vm.postulante.Tags" name="tags" placeholder="Adicionar Tags" display-property="nombre"
min-length="2" on-tag-added="vm.adicionarTag($tag)" on-tag-removed="vm.quitarTag($tag)">
<auto-complete source="vm.autoCompletarTags($query)" min-length="2"></auto-complete>
</tags-input>
<br>
<div class="pull-right">
<button class="btn btn-primary" type="submit">
Guardar
</button>
</div>
</form>
</div>
</uib-accordion-group>
<uib-accordion-group heading="Postulaciones" class="panel-primary" is-open="true">
......
......@@ -23,6 +23,12 @@
<input type="text" name="ci" class="form-control" ng-model="vm.postulante.ci" required>
</div>
<tag-manager tags="tags" autocomplete="allTags"></tag-manager>
<hr>
<h3>Current Tags</h3>
<ul class="list-unstyled">
<li ng-repeat="tag in tags">{{tag}}</li>
</ul>
<div class="form-group has-error">
......@@ -41,3 +47,5 @@
</div>
<hr>
</div>
......@@ -16,6 +16,10 @@
getTag(id) {
return this.resource.get({id: id});
}
crearTag(tag) {
return this.resource.save(tag).$promise;
}
}
angular.module('moduloPersonalApp')
......
......@@ -18,13 +18,19 @@
incluye: ['Postulante', 'Tag']
}).$promise;
}
gettagPostulante(id) {
return this.resource.get({id: id});
}
crearTagPostulante(tag) {
return this.resource.save(tag).$promise;
}
eliminarTagPostulante(id) {
return this.resource.remove({id: id}).$promise;
}
}
angular.module('moduloPersonalApp')
.service('tagPostulanteService', TagPostulanteService);
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment