@abp/core 6.0.1 → 7.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/abp.js +63 -34
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "
|
|
2
|
+
"version": "7.0.0-rc.2",
|
|
3
3
|
"name": "@abp/core",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@abp/utils": "~
|
|
13
|
+
"@abp/utils": "~7.0.0-rc.2"
|
|
14
14
|
},
|
|
15
15
|
"gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431"
|
|
16
16
|
}
|
package/src/abp.js
CHANGED
|
@@ -72,59 +72,90 @@ var abp = abp || {};
|
|
|
72
72
|
/* LOCALIZATION ***********************************************/
|
|
73
73
|
|
|
74
74
|
abp.localization = abp.localization || {};
|
|
75
|
-
|
|
75
|
+
abp.localization.internal = abp.localization.internal || {};
|
|
76
76
|
abp.localization.values = abp.localization.values || {};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
abp.localization.resources = abp.localization.resources || {};
|
|
78
|
+
|
|
79
|
+
abp.localization.internal.getResource = function (resourceName) {
|
|
80
|
+
var resource = abp.localization.resources[resourceName];
|
|
81
|
+
if (resource) {
|
|
82
|
+
return resource;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
var legacySource = abp.localization.values[resourceName];
|
|
86
|
+
if (legacySource) {
|
|
87
|
+
return {
|
|
88
|
+
texts: abp.localization.values[resourceName],
|
|
89
|
+
baseResources: []
|
|
90
|
+
};
|
|
81
91
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
92
|
+
|
|
93
|
+
abp.log.warn('Could not find localization source: ' + resourceName);
|
|
94
|
+
return null;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
abp.localization.internal.localize = function (key, sourceName) {
|
|
98
|
+
var resource = abp.localization.internal.getResource(sourceName);
|
|
99
|
+
if (!resource){
|
|
100
|
+
return {
|
|
101
|
+
value: key,
|
|
102
|
+
found: false
|
|
103
|
+
};
|
|
87
104
|
}
|
|
88
105
|
|
|
89
|
-
var
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
106
|
+
var value = resource.texts[key];
|
|
107
|
+
if (value === undefined) {
|
|
108
|
+
for (var i = 0; i < resource.baseResources.length; i++){
|
|
109
|
+
var basedArguments = Array.prototype.slice.call(arguments, 0);
|
|
110
|
+
basedArguments[1] = resource.baseResources[i];
|
|
94
111
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
112
|
+
var result = abp.localization.internal.localize.apply(this, basedArguments);
|
|
113
|
+
if (result.found){
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
value: key,
|
|
120
|
+
found: false
|
|
121
|
+
};
|
|
98
122
|
}
|
|
99
123
|
|
|
100
124
|
var copiedArguments = Array.prototype.slice.call(arguments, 0);
|
|
101
125
|
copiedArguments.splice(1, 1);
|
|
102
126
|
copiedArguments[0] = value;
|
|
103
127
|
|
|
104
|
-
return
|
|
128
|
+
return {
|
|
129
|
+
value: abp.utils.formatString.apply(this, copiedArguments),
|
|
130
|
+
found: true
|
|
131
|
+
};
|
|
105
132
|
};
|
|
106
133
|
|
|
107
|
-
abp.localization.
|
|
134
|
+
abp.localization.localize = function (key, sourceName) {
|
|
108
135
|
if (sourceName === '_') { //A convention to suppress the localization
|
|
109
|
-
return
|
|
136
|
+
return key;
|
|
110
137
|
}
|
|
111
138
|
|
|
112
139
|
sourceName = sourceName || abp.localization.defaultResourceName;
|
|
113
140
|
if (!sourceName) {
|
|
114
|
-
|
|
141
|
+
abp.log.warn('Localization source name is not specified and the defaultResourceName was not defined!');
|
|
142
|
+
return key;
|
|
115
143
|
}
|
|
116
144
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
145
|
+
return abp.localization.internal.localize.apply(this, arguments).value;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
abp.localization.isLocalized = function (key, sourceName) {
|
|
149
|
+
if (sourceName === '_') { //A convention to suppress the localization
|
|
150
|
+
return true;
|
|
120
151
|
}
|
|
121
152
|
|
|
122
|
-
|
|
123
|
-
if (
|
|
153
|
+
sourceName = sourceName || abp.localization.defaultResourceName;
|
|
154
|
+
if (!sourceName) {
|
|
124
155
|
return false;
|
|
125
156
|
}
|
|
126
157
|
|
|
127
|
-
return
|
|
158
|
+
return abp.localization.internal.localize(key, sourceName).found;
|
|
128
159
|
};
|
|
129
160
|
|
|
130
161
|
abp.localization.getResource = function (name) {
|
|
@@ -173,12 +204,10 @@ var abp = abp || {};
|
|
|
173
204
|
|
|
174
205
|
abp.auth = abp.auth || {};
|
|
175
206
|
|
|
176
|
-
abp.auth.policies = abp.auth.policies || {};
|
|
177
|
-
|
|
178
207
|
abp.auth.grantedPolicies = abp.auth.grantedPolicies || {};
|
|
179
208
|
|
|
180
209
|
abp.auth.isGranted = function (policyName) {
|
|
181
|
-
return abp.auth.
|
|
210
|
+
return abp.auth.grantedPolicies[policyName] != undefined;
|
|
182
211
|
};
|
|
183
212
|
|
|
184
213
|
abp.auth.isAnyGranted = function () {
|
|
@@ -687,7 +716,7 @@ var abp = abp || {};
|
|
|
687
716
|
}
|
|
688
717
|
|
|
689
718
|
/**
|
|
690
|
-
* Escape HTML to help prevent XSS attacks.
|
|
719
|
+
* Escape HTML to help prevent XSS attacks.
|
|
691
720
|
*/
|
|
692
721
|
abp.utils.htmlEscape = function (html) {
|
|
693
722
|
return typeof html === 'string' ? html.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"') : html;
|
|
@@ -759,7 +788,7 @@ var abp = abp || {};
|
|
|
759
788
|
return toUtc(date);
|
|
760
789
|
}
|
|
761
790
|
};
|
|
762
|
-
|
|
791
|
+
|
|
763
792
|
/* FEATURES *************************************************/
|
|
764
793
|
|
|
765
794
|
abp.features = abp.features || {};
|
|
@@ -774,7 +803,7 @@ var abp = abp || {};
|
|
|
774
803
|
abp.features.get = function (name) {
|
|
775
804
|
return abp.features.values[name];
|
|
776
805
|
};
|
|
777
|
-
|
|
806
|
+
|
|
778
807
|
/* GLOBAL FEATURES *************************************************/
|
|
779
808
|
|
|
780
809
|
abp.globalFeatures = abp.globalFeatures || {};
|