@fleetbase/ember-core 0.2.16 → 0.2.18

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.
@@ -0,0 +1,7 @@
1
+ import getModelName from './get-model-name';
2
+
3
+ export default function getModelSavePermission(service, model) {
4
+ const modelName = getModelName(model);
5
+ const ability = model && model.isNew ? 'create' : 'update';
6
+ return `${service} ${ability} ${modelName}`;
7
+ }
@@ -1,3 +1,9 @@
1
+ import { isBlank } from '@ember/utils';
2
+
1
3
  export default function isEmptyObject(obj) {
2
- return Object.keys(obj).length === 0 && obj.constructor === Object;
4
+ if (isBlank(obj)) {
5
+ return true;
6
+ }
7
+
8
+ return obj.constructor === Object && Object.keys(obj).length === 0;
3
9
  }
@@ -8,17 +8,12 @@ export default function serializeNormalizeRelationsWithinHash(hash, primaryKey =
8
8
 
9
9
  for (let attr in hash) {
10
10
  if (typeof attr === 'string' && attr.includes('_uuid')) {
11
- // console.log(attr, hash[attr]);
12
11
  if (typeof hash[attr] === 'object' && !isBlank(hash[attr])) {
13
12
  // the relation has loaded back into `_uuid` - change this to the proper `uuid` string value and set the relationship
14
13
  const relation = hash[attr];
15
14
  const id = get(relation, primaryKey);
16
15
  const relationAttr = attr.replace('_uuid', '');
17
16
 
18
- // console.log(`normalizing relation ${relationAttr} from ${attr}`);
19
- // console.log(relationAttr, relation);
20
- // console.log(attr, id);
21
-
22
17
  setProperties(hash, {
23
18
  [relationAttr]: relation,
24
19
  [attr]: id,
@@ -0,0 +1 @@
1
+ export { default } from '@fleetbase/ember-core/utils/get-model-save-permission';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetbase/ember-core",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "Provides all the core services, decorators and utilities for building a Fleetbase extension for the Console.",
5
5
  "keywords": [
6
6
  "fleetbase-core",