@openmrs/angularjs-openmrs-api
Advanced tools
Comparing version 0.7.2 to 0.8.0
@@ -471,3 +471,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
exports.default = angular.module('angularjs-openmrs-api-translate', ['pascalprecht.translate', _openmrsRest2.default]).factory('openmrsTranslateLoader', openmrsTranslateLoader).provider('openmrsTranslate', openmrsTranslateProvider).name; | ||
exports.default = angular.module('angularjs-openmrs-api-translate', ['pascalprecht.translate', _openmrsRest2.default]).factory('openmrsTranslateLoader', openmrsTranslateLoader).filter('translateAs', openmrsTranslateAs).provider('openmrsTranslate', openmrsTranslateProvider).name; | ||
@@ -498,2 +498,9 @@ /** | ||
openmrsTranslateAs.$inject['openmrsTranslate']; | ||
function openmrsTranslateAs(openmrsTranslate) { | ||
return function (input, type, name) { | ||
return openmrsTranslate.translateAs(input, type, name); | ||
}; | ||
} | ||
openmrsTranslateProvider.$inject = ['$translateProvider']; | ||
@@ -517,3 +524,3 @@ function openmrsTranslateProvider($translateProvider) { | ||
function provideOpenmrsTranslate($translate, $http, $q, openmrsRest) { | ||
function provideOpenmrsTranslate($translate, $http, $q, $filter, openmrsRest) { | ||
var language; | ||
@@ -563,6 +570,42 @@ | ||
/* Used to localize metadata based on our standard format for setting messages properties for metadata, ie: | ||
* ui.i18n.EncounterType.name.5C16E1D6-8E73-47E4-A861-D6AAC03E2224=Disposition | ||
* Standard use cases would be: | ||
* translateAs(encounterType, 'encounterType') | ||
* or | ||
* {{ encounterType | translateAs['encounterType'] }} | ||
* You can also specify the field if it's something other than name. We use this now for RelationshipTypes | ||
* which have two names (depending on the direction of the relationship): | ||
* {{ relationshipType | translateAs['relationshipType', 'aIstoB'] }} | ||
*/ | ||
function translateAs(input, type, field) { | ||
if (!field) { | ||
field = 'name'; | ||
} | ||
// first try to see if we have a custom translation property code | ||
if (input.uuid) { | ||
var code = "ui.i18n." + type + "." + field + "." + input.uuid; | ||
var result = $filter('translate')(code); | ||
if (result && result != code) { | ||
return result; | ||
} | ||
} | ||
if (input.display) { | ||
return input.display; | ||
} | ||
if (input[field]) { | ||
return input[field]; | ||
} | ||
if (input.name) { | ||
return input.name; | ||
} | ||
return ""; | ||
} | ||
return { | ||
changeLanguage: setLanguage, | ||
setLanguage: setLanguage, | ||
getLanguage: getLanguage | ||
getLanguage: getLanguage, | ||
translateAs: translateAs | ||
}; | ||
@@ -573,3 +616,3 @@ } | ||
addTranslations: addTranslations, | ||
$get: ['$translate', '$http', '$q', 'openmrsRest', provideOpenmrsTranslate] | ||
$get: ['$translate', '$http', '$q', '$filter', 'openmrsRest', provideOpenmrsTranslate] | ||
}; | ||
@@ -576,0 +619,0 @@ } |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("angular"),require("angular-resource"),require("angular-translate"),require("angular-translate-loader-url")):"function"==typeof define&&define.amd?define("angularjs-openmrs-api",["angular","angular-resource","angular-translate","angular-translate-loader-url"],n):"object"==typeof exports?exports["angularjs-openmrs-api"]=n(require("angular"),require("angular-resource"),require("angular-translate"),require("angular-translate-loader-url")):e["angularjs-openmrs-api"]=n(e.angular,e["angular-resource"],e["angular-translate"],e["angular-translate-loader-url"])}(this,function(e,n,r,t){return function(e){function n(t){if(r[t])return r[t].exports;var u=r[t]={i:t,l:!1,exports:{}};return e[t].call(u.exports,u,u.exports,n),u.l=!0,u.exports}var r={};return n.m=e,n.c=r,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=3)}([function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}function u(e,n,r,t){function u(){o("/owa/")}function o(e){var n=r.location.pathname;n=n.substring(0,n.indexOf(e)),n.endsWith("/")&&(n=n.substring(0,n.length-1)),t.href=n}function a(){var r=n.defer();return c.default.isDefined(t.href)?r.resolve(t):"undefined"!=typeof OPENMRS_CONTEXT_PATH?(t.href=OPENMRS_CONTEXT_PATH,r.resolve(t)):e.get("manifest.webapp").then(function(n){n.data.activities.openmrs.testConfig?(t.href=n.data.activities.openmrs.testConfig.href,t.test=!0,e.defaults.headers.common["Disable-WWW-Authenticate"]=!1,e.defaults.withCredentials=!0,r.resolve(t)):(u(),r.resolve(t))},function(e){u(),r.resolve(t)}),r.promise}return{getConfig:a,setBaseAppPath:o}}function o(e,n,r){return{responseError:function(t){var u=n.location.href;if(u=u.replace("#","_HASHTAG_"),!r.test&&(401===t.status||403===t.status)&&n.confirm("The operation cannot be completed, because you are no longer logged in. Do you want to go to login page?")){var o=r.href+"/login.htm?redirect_url="+u;n.location.href=o}return e.reject(t)}}}function a(e){e.interceptors.push("authInterceptor"),e.defaults.headers.common["Disable-WWW-Authenticate"]="true"}function i(e,n,r){function t(t){var o=n.defer();return r.getConfig().then(function(n){var r,a;if(c.default.isString(t)){t={resource:t,url:"/"+t}}if(t.unnatural)r=t.params,a=n.href+"/ws/rest/v1"+t.url+"/:uuid";else{var i=c.default.copy(u.defaultConfig);r=c.default.extend(i,t.params),a=n.href+"/ws/rest/v1"+t.url+"/:uuid"}var s=t.actions||u.extraActions;u[t.resource]=e(a,r,s),o.resolve(u[t.resource])}),o.promise}var u={defaultConfig:{uuid:"@uuid"},add:t};return u}function s(){function e(e,n){return["openmrsRest",function(r){return r.list(e,n)}]}function n(e,n){return["openmrsRest",function(r){return r.get(e,n)}]}function r(e,n,r,t){function u(){var e=r.defer();return t.getConfig().then(function(n){e.resolve(n.href)}),e.promise}function o(e){t.setBaseAppPath(e)}function a(r,t){return e.add(r).then(function(e){return e.get(t).$promise.then(function(e){return new l(e,n)})})}function i(e,n){return n=x(n,"full"),a(e,n)}function s(e,n){return n=x(n,"ref"),a(e,n)}function f(n,r){return e.add(n).then(function(e){return e.get(r).$promise.then(function(e){return e})})}function d(e,n){return n=x(n,"full"),f(e,n)}function p(e,n){return n=x(n,"ref"),f(e,n)}function g(n,r){return e.add(n).then(function(e){return e.save(r).$promise.then(function(e){return e})})}function m(n,r){return e.add(n).then(function(e){return e.save({uuid:r.uuid},r).$promise.then(function(e){return e})})}function h(n,r,t){return e.add(n).then(function(e){return e.remove({uuid:r.uuid,reason:t}).$promise.then(function(e){return e})})}function v(n,r){return e.add(n).then(function(e){return e.save({uuid:r.uuid},{retired:!1}).$promise.then(function(e){return e})})}function $(n,r){var t={uuid:r.uuid};return null==t?t={purge:!0}:c.default.extend(t,{purge:!0}),e.add(n).then(function(e){return e.remove(t).$promise.then(function(e){return e})})}function x(e,n){return null==e?{v:n}:c.default.extend(e,{v:n})}return{list:a,listFull:i,listRef:s,get:f,getFull:d,getRef:p,create:g,update:m,remove:h,retire:h,unretire:v,purge:$,getServerUrl:u,setBaseAppPath:o}}return{list:e,get:n,$get:["openmrsApi","$document","$q","openmrsContext",function(e,n,t,u){return r(e,n,t,u)}]}}function l(e,n){function r(){return null!=a}function t(){return null!=i}function u(e){var r=n[0].createElement("a");r.href=e;var t=r.search.slice(1).split("&"),u={};return t.forEach(function(e){""!==e&&(e=e.split("="),u[e[0]]=decodeURIComponent(e[1]||""))}),u}var o=e.results,a=null,i=null;return function(){if(null!=e.links)for(var n=0;n<e.links.length;n++){var r=e.links[n];"next"===r.rel?a=u(r.uri):"prev"===r.rel&&(i=u(r.uri))}}(),{results:o,hasNext:r,nextQuery:a,hasPrevious:t,previousQuery:i}}Object.defineProperty(n,"__esModule",{value:!0});var f=r(1),c=t(f),d=r(4);t(d);n.default=c.default.module("angularjs-openmrs-api-rest",["ngResource"]).value("openmrsContextConfig",{}).factory("openmrsContext",u).factory("openmrsApi",i).factory("authInterceptor",o).config(a).provider("openmrsRest",s).name,u.$inject=["$http","$q","$window","openmrsContextConfig"],o.$inject=["$q","$window","openmrsContextConfig"],a.$inject=["$httpProvider"],i.$inject=["$resource","$q","openmrsContext"]},function(e,n){e.exports=require("angular")},function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}function u(e,n){return function(r){return n.getServerUrl().then(function(n){return r.url=n+"/module/uicommons/messages/messages.json",r.queryParameter="localeKey",e(r)})}}function o(e){function n(n,r){var t=e.translations(n);angular.isDefined(t)||(t={}),e.translations(n,angular.extend(t,r))}function r(e,n,r,t){function u(n){e.use(n),t.create("session",{locale:n}).then(function(){console.log("Locale changed to "+n)})}function o(){var n=r.defer();return angular.isDefined(a)?n.resolve(a):t.get("session").then(function(r){null!=r.locale?(a=null!=r.locale.language?r.locale.language:r.locale,e.use(a)):a=e.use(),n.resolve(a)},function(r){a=e.use(),n.resolve(a)}),n.promise}var a;return function(){o()}(),{changeLanguage:u,setLanguage:u,getLanguage:o}}return function(){e.fallbackLanguage("en").preferredLanguage("en").useLoader("openmrsTranslateLoader").useSanitizeValueStrategy("escape").forceAsyncReload(!0)}(),{addTranslations:n,$get:["$translate","$http","$q","openmrsRest",r]}}Object.defineProperty(n,"__esModule",{value:!0});var a=r(5),i=(t(a),r(6)),s=(t(i),r(0)),l=t(s);n.default=angular.module("angularjs-openmrs-api-translate",["pascalprecht.translate",l.default]).factory("openmrsTranslateLoader",u).provider("openmrsTranslate",o).name,u.$inject=["$translateUrlLoader","openmrsRest"],o.$inject=["$translateProvider"]},function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=r(1),o=t(u),a=r(0),i=t(a),s=r(2),l=t(s);n.default=o.default.module("angularjs-openmrs-api",[i.default,l.default]).name},function(e,n){e.exports=require("angular-resource")},function(e,n){e.exports=require("angular-translate")},function(e,n){e.exports=require("angular-translate-loader-url")}])}); | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("angular"),require("angular-resource"),require("angular-translate"),require("angular-translate-loader-url")):"function"==typeof define&&define.amd?define("angularjs-openmrs-api",["angular","angular-resource","angular-translate","angular-translate-loader-url"],n):"object"==typeof exports?exports["angularjs-openmrs-api"]=n(require("angular"),require("angular-resource"),require("angular-translate"),require("angular-translate-loader-url")):e["angularjs-openmrs-api"]=n(e.angular,e["angular-resource"],e["angular-translate"],e["angular-translate-loader-url"])}(this,function(e,n,r,t){return function(e){function n(t){if(r[t])return r[t].exports;var u=r[t]={i:t,l:!1,exports:{}};return e[t].call(u.exports,u,u.exports,n),u.l=!0,u.exports}var r={};return n.m=e,n.c=r,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=3)}([function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}function u(e,n,r,t){function u(){a("/owa/")}function a(e){var n=r.location.pathname;n=n.substring(0,n.indexOf(e)),n.endsWith("/")&&(n=n.substring(0,n.length-1)),t.href=n}function o(){var r=n.defer();return c.default.isDefined(t.href)?r.resolve(t):"undefined"!=typeof OPENMRS_CONTEXT_PATH?(t.href=OPENMRS_CONTEXT_PATH,r.resolve(t)):e.get("manifest.webapp").then(function(n){n.data.activities.openmrs.testConfig?(t.href=n.data.activities.openmrs.testConfig.href,t.test=!0,e.defaults.headers.common["Disable-WWW-Authenticate"]=!1,e.defaults.withCredentials=!0,r.resolve(t)):(u(),r.resolve(t))},function(e){u(),r.resolve(t)}),r.promise}return{getConfig:o,setBaseAppPath:a}}function a(e,n,r){return{responseError:function(t){var u=n.location.href;if(u=u.replace("#","_HASHTAG_"),!r.test&&(401===t.status||403===t.status)&&n.confirm("The operation cannot be completed, because you are no longer logged in. Do you want to go to login page?")){var a=r.href+"/login.htm?redirect_url="+u;n.location.href=a}return e.reject(t)}}}function o(e){e.interceptors.push("authInterceptor"),e.defaults.headers.common["Disable-WWW-Authenticate"]="true"}function i(e,n,r){function t(t){var a=n.defer();return r.getConfig().then(function(n){var r,o;if(c.default.isString(t)){t={resource:t,url:"/"+t}}if(t.unnatural)r=t.params,o=n.href+"/ws/rest/v1"+t.url+"/:uuid";else{var i=c.default.copy(u.defaultConfig);r=c.default.extend(i,t.params),o=n.href+"/ws/rest/v1"+t.url+"/:uuid"}var s=t.actions||u.extraActions;u[t.resource]=e(o,r,s),a.resolve(u[t.resource])}),a.promise}var u={defaultConfig:{uuid:"@uuid"},add:t};return u}function s(){function e(e,n){return["openmrsRest",function(r){return r.list(e,n)}]}function n(e,n){return["openmrsRest",function(r){return r.get(e,n)}]}function r(e,n,r,t){function u(){var e=r.defer();return t.getConfig().then(function(n){e.resolve(n.href)}),e.promise}function a(e){t.setBaseAppPath(e)}function o(r,t){return e.add(r).then(function(e){return e.get(t).$promise.then(function(e){return new l(e,n)})})}function i(e,n){return n=x(n,"full"),o(e,n)}function s(e,n){return n=x(n,"ref"),o(e,n)}function f(n,r){return e.add(n).then(function(e){return e.get(r).$promise.then(function(e){return e})})}function d(e,n){return n=x(n,"full"),f(e,n)}function p(e,n){return n=x(n,"ref"),f(e,n)}function g(n,r){return e.add(n).then(function(e){return e.save(r).$promise.then(function(e){return e})})}function m(n,r){return e.add(n).then(function(e){return e.save({uuid:r.uuid},r).$promise.then(function(e){return e})})}function h(n,r,t){return e.add(n).then(function(e){return e.remove({uuid:r.uuid,reason:t}).$promise.then(function(e){return e})})}function v(n,r){return e.add(n).then(function(e){return e.save({uuid:r.uuid},{retired:!1}).$promise.then(function(e){return e})})}function $(n,r){var t={uuid:r.uuid};return null==t?t={purge:!0}:c.default.extend(t,{purge:!0}),e.add(n).then(function(e){return e.remove(t).$promise.then(function(e){return e})})}function x(e,n){return null==e?{v:n}:c.default.extend(e,{v:n})}return{list:o,listFull:i,listRef:s,get:f,getFull:d,getRef:p,create:g,update:m,remove:h,retire:h,unretire:v,purge:$,getServerUrl:u,setBaseAppPath:a}}return{list:e,get:n,$get:["openmrsApi","$document","$q","openmrsContext",function(e,n,t,u){return r(e,n,t,u)}]}}function l(e,n){function r(){return null!=o}function t(){return null!=i}function u(e){var r=n[0].createElement("a");r.href=e;var t=r.search.slice(1).split("&"),u={};return t.forEach(function(e){""!==e&&(e=e.split("="),u[e[0]]=decodeURIComponent(e[1]||""))}),u}var a=e.results,o=null,i=null;return function(){if(null!=e.links)for(var n=0;n<e.links.length;n++){var r=e.links[n];"next"===r.rel?o=u(r.uri):"prev"===r.rel&&(i=u(r.uri))}}(),{results:a,hasNext:r,nextQuery:o,hasPrevious:t,previousQuery:i}}Object.defineProperty(n,"__esModule",{value:!0});var f=r(1),c=t(f),d=r(4);t(d);n.default=c.default.module("angularjs-openmrs-api-rest",["ngResource"]).value("openmrsContextConfig",{}).factory("openmrsContext",u).factory("openmrsApi",i).factory("authInterceptor",a).config(o).provider("openmrsRest",s).name,u.$inject=["$http","$q","$window","openmrsContextConfig"],a.$inject=["$q","$window","openmrsContextConfig"],o.$inject=["$httpProvider"],i.$inject=["$resource","$q","openmrsContext"]},function(e,n){e.exports=require("angular")},function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}function u(e,n){return function(r){return n.getServerUrl().then(function(n){return r.url=n+"/module/uicommons/messages/messages.json",r.queryParameter="localeKey",e(r)})}}function a(e){return function(n,r,t){return e.translateAs(n,r,t)}}function o(e){function n(n,r){var t=e.translations(n);angular.isDefined(t)||(t={}),e.translations(n,angular.extend(t,r))}function r(e,n,r,t,u){function a(n){e.use(n),u.create("session",{locale:n}).then(function(){console.log("Locale changed to "+n)})}function o(){var n=r.defer();return angular.isDefined(s)?n.resolve(s):u.get("session").then(function(r){null!=r.locale?(s=null!=r.locale.language?r.locale.language:r.locale,e.use(s)):s=e.use(),n.resolve(s)},function(r){s=e.use(),n.resolve(s)}),n.promise}function i(e,n,r){if(r||(r="name"),e.uuid){var u="ui.i18n."+n+"."+r+"."+e.uuid,a=t("translate")(u);if(a&&a!=u)return a}return e.display?e.display:e[r]?e[r]:e.name?e.name:""}var s;return function(){o()}(),{changeLanguage:a,setLanguage:a,getLanguage:o,translateAs:i}}return function(){e.fallbackLanguage("en").preferredLanguage("en").useLoader("openmrsTranslateLoader").useSanitizeValueStrategy("escape").forceAsyncReload(!0)}(),{addTranslations:n,$get:["$translate","$http","$q","$filter","openmrsRest",r]}}Object.defineProperty(n,"__esModule",{value:!0});var i=r(5),s=(t(i),r(6)),l=(t(s),r(0)),f=t(l);n.default=angular.module("angularjs-openmrs-api-translate",["pascalprecht.translate",f.default]).factory("openmrsTranslateLoader",u).filter("translateAs",a).provider("openmrsTranslate",o).name,u.$inject=["$translateUrlLoader","openmrsRest"],a.$inject.openmrsTranslate,o.$inject=["$translateProvider"]},function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=r(1),a=t(u),o=r(0),i=t(o),s=r(2),l=t(s);n.default=a.default.module("angularjs-openmrs-api",[i.default,l.default]).name},function(e,n){e.exports=require("angular-resource")},function(e,n){e.exports=require("angular-translate")},function(e,n){e.exports=require("angular-translate-loader-url")}])}); | ||
//# sourceMappingURL=index.min.js.map |
{ | ||
"name": "@openmrs/angularjs-openmrs-api", | ||
"version": "0.7.2", | ||
"version": "0.8.0", | ||
"description": "AngularJS (1.x) library for OpenMRS API", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124241
605