Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SistemaGestionAdministrativa
ModuloPersonalCliente
Commits
5bb6c253
Commit
5bb6c253
authored
Jun 13, 2016
by
Teodoro David Nina Mamani
Browse files
Se crearon los servicios de la vista, para agregar oficina a entidad.
parent
6f7340ab
Changes
14
Show whitespace changes
Inline
Side-by-side
client/app/entidades/editar/entidades.editar.controller.js
View file @
5bb6c253
...
...
@@ -108,7 +108,6 @@
.
then
(
resultado
=>
{
unidadOrganizacional
.
OficinaUnidad
=
resultado
.
OficinaUnidad
;
unidadOrganizacional
.
Cargos
=
resultado
.
Cargos
;
console
.
log
(
resultado
);
})
}
}
...
...
client/app/entidades/editar/entidades.editar.html
View file @
5bb6c253
...
...
@@ -129,5 +129,6 @@
</blockquote>
</div>
</div>
</div>
</div>
</div>
client/app/entidades/entidades.html
View file @
5bb6c253
<div
class=
"container-fluid"
>
<div
ui-view
></div>
<div
ui-view=
"entidad"
></div>
<div
ui-view=
"
convocatorias
"
></div>
<div
ui-view=
"
oficinasEntidad
"
></div>
<div
ui-view=
"unidadesOrganizacionales"
></div>
</div>
client/app/entidades/entidades.js
View file @
5bb6c253
...
...
@@ -22,6 +22,11 @@ angular.module('moduloPersonalApp')
controller
:
'
EntidadEditarCtrl
'
,
controllerAs
:
'
vm
'
},
"
oficinasEntidad
"
:
{
templateUrl
:
'
app/oficinas/editar/oficinas.editar.html
'
,
controller
:
'
OficinaEditarCtrl
'
,
controllerAs
:
'
vm
'
},
"
convocatorias
"
:
{
templateUrl
:
'
app/convocatorias/convocatorias.html
'
,
controller
:
'
ConvocatoriaCtrl
'
,
...
...
client/app/entidades/entidades.service.js
View file @
5bb6c253
...
...
@@ -5,12 +5,18 @@
constructor
(
$resource
,
appConfig
)
{
this
.
resource
=
$resource
(
appConfig
.
serverAddress
+
'
/api/entidades/:id
'
,
{
id
:
'
@_id
'
},
{
},
{
update
:
{
method
:
'
PUT
'
},
query
:
{
isArray
:
false
},
organigrama
:
{
method
:
'
GET
'
,
url
:
appConfig
.
serverAddress
+
'
/api/entidades/:id/organigrama
'
},
oficinas
:{
method
:
'
GET
'
,
isArray
:
true
,
url
:
appConfig
.
serverAddress
+
'
/api/entidades/:id/oficinas
'
}
})
}
...
...
@@ -18,7 +24,6 @@
getEntidades
(
parametros
)
{
return
this
.
resource
.
query
(
parametros
).
$promise
;
}
getEntidad
(
id
,
parametros
=
{})
{
parametros
.
id
=
id
;
return
this
.
resource
.
get
(
parametros
).
$promise
;
...
...
@@ -28,12 +33,16 @@
return
this
.
resource
.
organigrama
({
id
:
id
}).
$promise
;
}
getOficinas
(
id
)
{
//parametros.id = id;
return
this
.
resource
.
oficinas
({
id
:
id
}).
$promise
;
}
crearEntidad
(
entidad
)
{
return
this
.
resource
.
save
(
entidad
).
$promise
;
}
editarEntidad
(
id
,
entidad
)
{
console
.
log
(
entidad
);
return
this
.
resource
.
update
({
id
:
id
},
entidad
).
$promise
;
}
}
...
...
client/app/oficinas/editar/oficinas.editar.controller.js
0 → 100644
View file @
5bb6c253
(()
=>
{
'
use strict
'
;
class
OficinaEditarController
{
constructor
(
$stateParams
,
EntidadService
,
OficinaService
,
$uibModal
,
Modal
){
this
.
errores
=
{};
// lista de errores
this
.
alertasOficinaEntidad
=
[];
this
.
modal
=
$uibModal
;
this
.
Modal
=
Modal
;
this
.
entidadService
=
EntidadService
;
this
.
oficinaService
=
OficinaService
;
this
.
entidadId
=
$stateParams
.
entidadId
;
this
.
entidadService
.
getOficinas
(
this
.
entidadId
)
.
then
(
oficinas
=>
{
this
.
oficinas
=
oficinas
;
})
}
crearOficinaEntidad
(
entidad
)
{
var
this_
=
this
;
this
.
modal
.
open
({
templateUrl
:
'
app/oficinas/modals/oficinas.entidad.modal.html
'
,
controller
:
'
OficinaEntidadCrearModalCtrl
'
,
controllerAs
:
'
vm
'
,
resolve
:
{
parametro
:
{
entidadId
:
this
.
entidadId
}
}
}).
result
.
then
(
oficina
=>
{
this_
.
oficinas
.
push
(
oficina
);
this_
.
alertasOficinaEntidad
.
push
({
tipo
:
'
success
'
,
mensaje
:
'
Se creo correctamente la oficina:
'
+
oficina
.
nombre
})
})
}
editarOficinaEntidad
(
oficina
)
{
this
.
modal
.
open
({
templateUrl
:
'
app/oficinas/modals/oficinas.entidad.modal.html
'
,
controller
:
'
OficinaEntidadEditarModalCtrl
'
,
controllerAs
:
'
vm
'
,
resolve
:
{
parametro
:
{
entidadId
:
this
.
entidadId
,
oficina
:
oficina
}
}
}).
result
.
then
(
oficina
=>
{
var
oficinas
=
this
.
oficinas
.
find
(
x
=>
x
.
_id
==
oficina
.
_id
).
oficina
||
[];
this
.
alertasOficinaEntidad
.
push
({
tipo
:
'
success
'
,
mensaje
:
'
Se editó correctamente la oficina:
'
+
oficina
.
nombre
});
oficinas
.
push
(
oficina
);
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
});
}
eliminarOficinaEntidad
(
oficina
)
{
this
.
Modal
.
confirm
.
eliminar
(
oficina
=>
{
this
.
oficinaService
.
eliminarOficina
(
oficina
.
_id
).
then
(()
=>
{
this
.
oficinas
.
splice
(
this
.
oficinas
.
indexOf
(
oficina
),
1
);
this
.
alertasOficinaEntidad
.
push
({
tipo
:
'
danger
'
,
mensaje
:
'
La oficina fue correctamente eliminada
'
});
});
})(
oficina
.
nombre
,
oficina
);
}
}
angular
.
module
(
'
moduloPersonalApp
'
)
.
controller
(
'
OficinaEditarCtrl
'
,
OficinaEditarController
);
})();
client/app/oficinas/editar/oficinas.editar.html
0 → 100644
View file @
5bb6c253
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-sm-5 col-md-4 col-xs-6"
>
<h4
class=
"color-primary"
>
Oficinas de la Entidad
</h4>
</div>
<div
class=
"col-sm-5 col-md-4 col-sm-offset-2"
>
<div
class=
"pull-right"
>
<button
class=
"btn btn-success-outline"
ng-click=
"vm.crearOficinaEntidad()"
type=
"button"
><i
class=
"fa fa-plus"
></i>
Añadir Oficina
</button>
</div>
</div>
</div>
<div
class=
"col-md-10"
>
<uib-alert
ng-repeat=
"alerta in vm.alertasOficinaEntidad"
type=
"{{alerta.tipo}}"
close=
"vm.alertasOficinaEntidad.splice($index,1)"
dismiss-on-timeout=
"3000"
>
{{alerta.mensaje}}
</uib-alert>
</div>
<blockquote
class=
"col-md-12 blockquote-primary"
>
<div
class=
"row"
>
<div
class=
"table-responsive col-md-10"
>
<table
class=
"table table-hover"
>
<thead>
<tr>
<th><a
href=
""
ng-click=
"vm.ordenar('nombre')"
>
Nombre
</a></th>
<th>
Ubicación
</th>
<th><a
href=
""
ng-click=
"vm.ordenar('pais')"
>
País
</a></th>
<th
class=
"text-center"
width=
"12%"
>
Tipo
</th>
<th
class=
"text-center"
width=
"12%"
>
Acciones
</th>
</tr>
</thead>
<tbody>
<tr
ng-repeat=
"oficina in vm.oficinas"
>
<td>
{{oficina.nombre}}
</td>
<td><a
href=
"https://www.google.com/maps?q={{oficina.latitud}},{{oficina.longitud}}"
>
Ubicación
</a></td>
<td>
{{oficina.pais}}
</td>
<td><label
class=
"label label-success"
ng-show=
"oficina.principal"
>
Oficina principal
</label><td>
<td
class=
"text-center"
>
<div
class=
"btn-group"
role=
"group"
>
<a
class=
"btn btn-info-outline btn-xs"
href=
"#"
role=
"button"
ng-click=
"vm.editarOficinaEntidad(oficina)"
>
<i
class=
"fa fa-edit fa-lg"
></i>
</a>
<a
class=
"btn btn-danger-outline btn-xs"
href=
"#"
role=
"button"
ng-click=
"vm.eliminarOficinaEntidad(oficina)"
>
<i
class=
"fa fa-trash fa-lg"
></i>
</a>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</blockquote>
</div>
client/app/oficinas/modals/oficina.entidad.crear.modal.controller.js
0 → 100644
View file @
5bb6c253
'
use strict
'
;
(()
=>
{
class
OficinaEntidadCrearModalController
{
constructor
(
$uibModalInstance
,
parametro
,
OficinaService
,
EntidadService
)
{
this
.
enviado
=
false
;
this
.
errores
=
{};
this
.
modal
=
$uibModalInstance
;
this
.
service
=
OficinaService
;
this
.
entidadService
=
EntidadService
;
this
.
entidadId
=
parametro
.
entidadId
;
this
.
entidadService
.
getEntidad
(
this
.
entidadId
)
.
then
(
entidad
=>
{
this
.
entidad
=
entidad
;
})
this
.
oficina
=
{};
}
guardarOficinaEntidad
(
form
)
{
this
.
enviado
=
true
;
if
(
form
.
$valid
)
{
this
.
oficina
.
fk_entidad
=
this
.
entidadId
;
this
.
service
.
crearOficina
(
this
.
oficina
)
.
then
(
oficina
=>
{
this
.
modal
.
close
(
oficina
);
})
.
catch
(
err
=>
{
this
.
errores
.
otros
=
err
.
data
.
message
;
})
}
}
}
angular
.
module
(
'
moduloPersonalApp
'
)
.
controller
(
'
OficinaEntidadCrearModalCtrl
'
,
OficinaEntidadCrearModalController
);
})();
client/app/oficinas/modals/oficina.entidad.editar.modal.controller.js
0 → 100644
View file @
5bb6c253
'
use strict
'
;
(()
=>
{
class
OficinaEntidadEditarModalController
{
constructor
(
$uibModalInstance
,
parametro
,
OficinaService
,
EntidadService
)
{
this
.
enviado
=
false
;
this
.
errores
=
{};
this
.
modal
=
$uibModalInstance
;
this
.
service
=
OficinaService
;
this
.
entidadService
=
EntidadService
;
this
.
entidadId
=
parametro
.
entidadId
;
this
.
oficina
=
parametro
.
oficina
;
this
.
entidadService
.
getEntidad
(
this
.
entidadId
)
.
then
(
entidad
=>
{
this
.
entidad
=
entidad
;
})
}
guardarOficinaEntidad
(
form
)
{
this
.
enviado
=
true
;
if
(
form
.
$valid
)
{
this
.
oficina
.
fk_entidad
=
this
.
entidadId
;
this
.
service
.
editarOficina
(
this
.
oficina
.
_id
,
this
.
oficina
)
.
then
(
oficina
=>
{
this
.
oficina
=
Object
.
assign
(
this
.
oficina
,
oficina
);
this
.
modal
.
close
(
oficina
);
})
.
catch
(
err
=>
{
this
.
errores
.
otros
=
err
.
data
.
message
;
})
}
}
}
angular
.
module
(
'
moduloPersonalApp
'
)
.
controller
(
'
OficinaEntidadEditarModalCtrl
'
,
OficinaEntidadEditarModalController
);
})();
client/app/oficinas/modals/oficinas.crear.modal.controller.js
View file @
5bb6c253
'
use strict
'
;
(()
=>
{
class
OficinaCrearModalC
ontroller
{
class
OficinaCrearModalC
trl
{
constructor
(
$uibModalInstance
,
parametro
,
OficinaService
,
OficinaUnidadService
,
EntidadService
,
UnidadService
)
{
this
.
enviado
=
false
;
this
.
errores
=
{};
...
...
@@ -59,12 +59,11 @@
});
})
.
catch
(
err
=>
{
console
.
log
(
err
);
this
.
errores
.
otros
=
err
.
data
.
message
;
})
}
}
}
angular
.
module
(
'
moduloPersonalApp
'
)
.
controller
(
'
OficinaCrearModalCtrl
'
,
OficinaCrearModalC
ontroller
);
.
controller
(
'
OficinaCrearModalCtrl
'
,
OficinaCrearModalC
trl
);
})();
client/app/oficinas/modals/oficinas.editar.modal.controller.js
View file @
5bb6c253
...
...
@@ -22,7 +22,6 @@
this
.
oficinaInicial
=
parametro
.
oficina
;
this
.
oficina
=
Object
.
assign
({},
parametro
.
oficina
);
this
.
oficinaUnidad
=
this
.
oficina
.
OficinaUnidad
;
console
.
log
(
this
.
oficina
);
}
guardarOficinaUnidad
(
form
)
{
...
...
client/app/oficinas/modals/oficinas.entidad.modal.html
0 → 100644
View file @
5bb6c253
<form
class=
"form"
name=
"form"
ng-submit=
"vm.guardarOficinaEntidad(form)"
novalidate
>
<div
class=
"modal-header modal-header-primary "
>
<button
type=
"button"
ng-click=
"vm.modal.dismiss()"
class=
"close"
>
×
</button>
<h4
class=
"modal-title"
>
Oficina
</h4>
</div>
<div
class=
"modal-body"
>
<div
class=
"row"
>
<div
class=
"col-md-10"
>
<label>
Entidad
</label>
<div
class=
""
>
<input
type=
"text"
name=
"entidad"
class=
"form-control"
placeholder=
"Nombre de la Entidad"
ng-model=
"vm.entidad.nombre"
ng-readonly=
"true"
>
<p
class=
"help-block"
ng-show=
"form.entidades.$error.required && vm.enviado"
>
Seleccione Entidad.
</p>
</div>
</div>
<div
class=
"col-md-10"
>
<label>
Nombre
</label>
<div
class=
""
>
<input
type=
"text"
name=
"nombre"
class=
"form-control"
placeholder=
"Nombre de la oficina"
ng-model=
"vm.oficina.nombre"
required
>
<p
class=
"help-block"
ng-show=
"form.nombre.$error.required && vm.enviado"
>
Ingrese el nombre de la Oficina.
</p>
</div>
</div>
<div
class=
"col-md-10"
>
<label>
Longitud
</label>
<div
class=
""
>
<input
type=
"text"
name=
"longitud"
class=
"form-control"
placeholder=
"Coordenada longitud"
ng-model=
"vm.oficina.longitud"
>
<p
class=
"help-block"
ng-show=
"form.longitud.$error.required && vm.enviado"
>
Ingrese las coordenadas longitud para la oficina.
</p>
</div>
</div>
<div
class=
"col-md-10"
>
<label>
Latitud
</label>
<div
class=
""
>
<input
type=
"text"
name=
"latitud"
class=
"form-control"
placeholder=
"Coordenada latitud"
ng-model=
"vm.oficina.latitud"
>
<p
class=
"help-block"
ng-show=
"form.latitud.$error.required && vm.enviado"
>
Ingrese las coordenadas latitud para la oficina.
</p>
</div>
</div>
<div
class=
"col-md-10"
>
<label>
País
</label>
<div
class=
""
>
<input
type=
"text"
name=
"pais"
class=
"form-control"
placeholder=
"País"
ng-model=
"vm.oficina.pais"
>
<p
class=
"help-block"
ng-show=
"form.pais.$error.required && vm.enviado"
>
Ingrese país.
</p>
</div>
</div>
<div
class=
"col-md-10"
>
<label>
Principal
</label>
<div
class=
""
>
<input
class=
"with-font"
type=
"checkbox"
id=
"principal"
name=
"principal"
value=
"true"
ng-model=
"vm.oficina.principal"
>
<label
for=
"principal"
>
{{vm.oficina.principal?'Es oficina principal':'No es principal'}}
</label>
</div>
</div>
</div>
<div
class=
"form-group has-error"
>
<p
class=
"help-block"
>
{{ vm.errores.otros}}
</p>
</div>
</div>
<div
class=
"modal-footer"
>
<button
class=
"btn btn-primary-outline"
type=
"submit"
ng-disabled=
"!(form.entidad.$dirty || form.nombre.$dirty || form.longitud.$dirty||form.latitud.$dirty||form.pais.$dirty || form.principal.$dirty)"
>
Guardar
</button>
<button
class=
"btn btn-default"
type=
"button"
ng-click=
"vm.modal.dismiss()"
>
Cancelar
</button>
</div>
</form>
client/app/oficinas/oficinas.service.js
View file @
5bb6c253
client/index.html
View file @
5bb6c253
...
...
@@ -73,7 +73,7 @@
<script
src=
"components/autenticacion/autenticacion.module.js"
></script>
<script
src=
"components/modal/modal.module.js"
></script>
<script
src=
"components/util/util.module.js"
></script>
<script
src=
"app/personas/personas.js"
></script>
<script
src=
"app/personas/personas.
controller.
js"
></script>
<script
src=
"app/cargos/editar/cargos.editar.controller.js"
></script>
<script
src=
"app/cargos/modals/cargos.crear.modal.controller.js"
></script>
<script
src=
"app/cargos/modals/cargos.editar.modal.controller.js"
></script>
...
...
@@ -101,14 +101,17 @@
<script
src=
"app/entidadesOficina/entidadesOficina.service.js"
></script>
<script
src=
"app/main/main.controller.js"
></script>
<script
src=
"app/main/main.js"
></script>
<script
src=
"app/oficinas/editar/oficinas.editar.controller.js"
></script>
<script
src=
"app/oficinas/modals/oficina.entidad.crear.modal.controller.js"
></script>
<script
src=
"app/oficinas/modals/oficina.entidad.editar.modal.controller.js"
></script>
<script
src=
"app/oficinas/modals/oficinas.crear.modal.controller.js"
></script>
<script
src=
"app/oficinas/modals/oficinas.editar.modal.controller.js"
></script>
<script
src=
"app/oficinas/oficinas.service.js"
></script>
<script
src=
"app/oficinasUnidad/oficinasUnidad.service.js"
></script>
<script
src=
"app/personas/editar/personas.editar.controller.js"
></script>
<script
src=
"app/personas/modals/personas.crear.modal.controller.js"
></script>
<script
src=
"app/personas/personas.controller.js"
></script>
<script
src=
"app/cargos/cargos.controller.js"
></script>
<script
src=
"app/personas/personas.js"
></script>
<script
src=
"app/personas/personas.service.js"
></script>
<script
src=
"app/postulaciones/modals/postulaciones.cargo.modal.controller.js"
></script>
<script
src=
"app/postulaciones/modals/postulaciones.crear.modal.controller.js"
></script>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment