Skip to content

Instantly share code, notes, and snippets.

@kutyel
Created October 20, 2015 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kutyel/28bfe7a1476ec7d3647d to your computer and use it in GitHub Desktop.
Save kutyel/28bfe7a1476ec7d3647d to your computer and use it in GitHub Desktop.
Atom Custom AngularJS Snippets
# Your snippets
".js":
"RunFacade":
prefix: "rf"
body: "function $1() {\n
\tvar req = {\n
\t\t'pe_entorno': helper.util.getEntorno(),\n
'pe_codusuario': helper.util.getUserConex(),\n
\t\t'pe_codaplicacion': helper.util.getCodAplicacion()\n
\t};\n
\treturn helper.util.runFacade(PL_PACKAGE, '$2', req)\n
\t.success((res) => {\n
\t\tif(res.RETVAL !== -1) {\n
\t\t\treturn Promise.reject({ 'val': true, 'mensaje': res.PS_ERROR });\n
\t\t}\n
\t\tvm.$3 = res.$4;\n
\t\treturn vm.$3;\n
\t});\n
}"
"Permisos":
prefix: "per"
body: "function obtenerPermisos(cod) {\n
\treturn helper.util.verPermiso(cod)\n
\t.success(function(res) {\n
\t\tif(!res.PS_PERMISO) {\n
\t\t\treturn Promise.reject({ 'val': true, 'mensaje': `Operación no permitida. No tiene permisos para la opción: ${cod} - ${res.PS_DESCRIP}.` });\n
\t\t}\n
\t\treturn res.RETVAL;\n
\t});\n
}"
"Promise Chain":
prefix: "ch"
body: "function init() {\n
\tutil.establecerCargando(true, true);\n
\thelper.obtenerPermisos(PERMISO)\n
\t.success(helper.$1)\n
\t.success(helper.$2)\n
\t.error((data, status) => (data.val) ? util.mostrarAviso(data)\n
\t: util.lanzarError({\n
\t\t'mensaje': 'No se ha podido obtener los permisos del usuario.',\n
\t\t'data': data,\n
\t\t'status': status\n
\t}))\n
\t.finally(() => util.establecerCargando(false, true));\n
}"
"Array Modelo":
prefix: "arr"
body: "modelo.$1 = [\n
\t{ 'key': '$2', 'value': '$3' },\n
\t{ 'key': '$2', 'value': '$3' },\n
\t{ 'key': '$2', 'value': '$3' },\n
\t{ 'key': '$2', 'value': '$3' },\n
\t{ 'key': '$2', 'value': '$3' }\n
];"
".html":
"Debugger JSON":
prefix: "deb"
body: '<div class="col-lg-12">\n
\t<pre>{{ modelo.$1 | json }}</pre>\n
</div>'
"UISelect":
prefix: "uiselect"
body: '<div ng-class="{ \'has-error\' : form.$1.$invalid && !form.$1.$pristine }">\n
\t<label class="col-sm-1 control-label" style="font-weight: normal;">$2</label>\n
\t<div class="col-sm-4">\n
\t\t<ui-select ng-model="modelo.$2" name="$1" title="$2" required>\n
\t\t\t<ui-select-match placeholder="Seleccione...">{{$select.selected.key}}</ui-select-match>\n
\t\t\t<ui-select-choices repeat="x in modelo.$4 | filter: $select.search">\n
\t\t\t\t<div ng-bind-html="x.key | highlight: $select.search"></div>\n
\t\t\t</ui-select-choices>\n
\t\t</ui-select>\n
\t</div>\n
</div>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment