Skip to content

Commit

Permalink
Update handling of Ember Record Identifiers (#690)
Browse files Browse the repository at this point in the history
* use internal EmberId

* Intial feature upgrade for Ember Internal Id

* upgrade app to use yarn v4

* remove comments

* fixed mdcodes dropdown
  • Loading branch information
dvonanderson authored Dec 18, 2024
1 parent befd968 commit 7f076e3
Show file tree
Hide file tree
Showing 26 changed files with 21,963 additions and 15,708 deletions.
4 changes: 0 additions & 4 deletions .bowerrc

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jsconfig.json
/.node_modules.ember-try/
/bower.json.ember-try
/package.json.ember-try
/mdeditor-test-fullset-20211206.json

.DS_Store
.vscode

.yarn/*
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

28 changes: 28 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# unconventional js
/blueprints/*/files/
/vendor/

# compiled output
/dist/
/tmp/

# dependencies
/bower_components/
/node_modules/

# misc
/coverage/
!.*
.eslintcache
.lint-todo/

# ember-try
/.node_modules.ember-try/
/bower.json.ember-try
/npm-shrinkwrap.json.ember-try
/package.json.ember-try
/package-lock.json.ember-try
/yarn.lock.ember-try


.yarn/*
15 changes: 12 additions & 3 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
"use strict";
// prettier.config.js, .prettierrc.js, prettier.config.cjs, or .prettierrc.cjs

module.exports = {
/**
* @see https://prettier.io/docs/en/configuration.html
* @type {import("prettier").Config}
*/
const config = {
trailingComma: 'es5',
tabWidth: 2,
semi: true,
singleQuote: true,
};
}

module.exports = config
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ You will need the following things properly installed on your computer.

- [Git][git]
- [Node.js][node]
- Supported versions: `v16`.
- Supported versions: `v18`.
- **Apple Silicon Users**: if you experience problems building or running try Node v14.
- We are now using Yarn V4. Here are the steps in setting it up.
- Make sure that you have Node Version 18 doesn't matter the minor semantic changes.
- Enable corepack by using the `corepack enable` command.
- Remove `node_modules` folder
- Run `yarn` to install packages again using Yarn V4.
- All other commands are the same.
- [Yarn][yarn] installed globally
- [Google Chrome][chrome]
- [Firefox][firefox]
Expand Down
16 changes: 13 additions & 3 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import Adapter
from 'ember-local-storage/adapters/adapter';
import Adapter from 'ember-local-storage/adapters/adapter';
import { v4 } from 'uuid';

export default Adapter.extend({});
export default Adapter.extend({
generateIdForRecord(store, type, inputProperties) {
if (!inputProperties.uuid) {
let uuid = v4();
let shortId = uuid.split('-')[0];
inputProperties.uuid = uuid;
return shortId;
}
return inputProperties.uuid.split('-')[0];
},
});
65 changes: 5 additions & 60 deletions app/models/contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import EmberObject, {
import {
Copyable
} from 'ember-copy'
import uuidV4 from 'uuid/v4';
import Validator from 'validator';
import Model from 'mdeditor/models/base';
import {
validator,
Expand All @@ -37,7 +35,7 @@ const Validations = buildValidations({
message: "Name should not be only white-space."
}),
validator('presence', {
disabled: notEmpty('model.json.positionName'),
disabled: notEmpty('model.json.name'),
presence: true
})
],
Expand All @@ -49,7 +47,7 @@ const Validations = buildValidations({
message: "Position Name should not be only white-space."
}),
validator('presence', {
disabled: notEmpty('model.json.name'),
disabled: notEmpty('model.json.postiionName'),
presence: true
})
],
Expand All @@ -63,10 +61,10 @@ const JsonDefault = EmberObject.extend({
init() {
this._super(...arguments);
this.setProperties({
'contactId': uuidV4(),
'contactId': null,
'isOrganization': false,
'name': null,
//'positionName': null,
'positionName': null,
'memberOfOrganization': [],
'logoGraphic': [],
'phone': [],
Expand All @@ -75,8 +73,6 @@ const JsonDefault = EmberObject.extend({
'externalIdentifier': [],
'onlineResource': [],
'hoursOfService': [],
//'contactInstructions': null,
//'contactType': null;
});
}
});
Expand Down Expand Up @@ -149,37 +145,6 @@ const Contact = Model.extend(Validations, Copyable, {
return json.name || (json.isOrganization ? null : json.positionName);
}),

// /**
// * The formatted display string for the contact
// *
// * @property title
// * @type {String}
// * @readOnly
// * @category computed
// * @requires json.name, json.positionName
// */
// updateMembers: Ember.observer('json.memberOfOrganization.[]',
// function () {
// //const me = this;
// const json = this.get('json');
// const value = json.memberOfOrganization;
//
// let store = this.get('store');
// let contacts = store.peekAll('contact');
// let organizations = this.get('organizations')
// .clear();
//
// value.forEach(function (id) {
// let rec = contacts.findBy('json.contactId', id);
//
// if(rec) {
// organizations.pushObject(rec);
// }
// //rec.get('contacts').pushObject(me);
// });
//
// }),

/**
* The type of contact
*
Expand Down Expand Up @@ -318,26 +283,6 @@ const Contact = Model.extend(Validations, Copyable, {
return combinedName;
}),

/**
* The trimmed varsion of the contactId.
*
* @property shortId
* @type {String}
* @readOnly
* @category computed
* @requires json.contactId
*/
shortId: computed('json.contactId', function () {
const contactId = this.get('json.contactId');
if(contactId && Validator.isUUID(contactId)) {
let index = contactId.indexOf('-');

return contactId.substring(0, index);
}

return contactId;
}),

/**
* A list of schema errors return by the validator.
*
Expand Down Expand Up @@ -395,7 +340,7 @@ const Contact = Model.extend(Validations, Copyable, {
isOrganization: isOrganization,
name: name ? `Copy of ${name}` : null,
positionName: name ? positionName : `Copy of ${positionName}`,
contactId: uuidV4()
contactId: null,
});

return this.store.createRecord('contact', {
Expand Down
5 changes: 2 additions & 3 deletions app/models/dictionary.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { attr } from '@ember-data/model';
import { Copyable } from 'ember-copy'
import uuidV4 from "uuid/v4";
import { alias } from '@ember/object/computed';
import Model from 'mdeditor/models/base';
import {
Expand Down Expand Up @@ -40,7 +39,7 @@ const JsonDefault = EmberObject.extend({
init() {
this._super(...arguments);
this.setProperties({
dictionaryId: uuidV4(),
dictionaryId: null,
dataDictionary: {
citation: {
title: null,
Expand Down Expand Up @@ -138,7 +137,7 @@ export default Model.extend(Validations, Copyable, {
let json = EmberObject.create(current);
let name = current.dataDictionary.citation.title;
json.set('dataDictionary.citation.title', `Copy of ${name}`);
json.set('dictionaryId', uuidV4());
json.set('dictionaryId', null);

return this.store.createRecord('dictionary', {
json: json
Expand Down
5 changes: 2 additions & 3 deletions app/models/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { alias } from '@ember/object/computed';
import { getOwner } from '@ember/application';
import EmberObject, { computed, getWithDefault } from '@ember/object';
import { Copyable } from 'ember-copy';
import uuidV4 from "uuid/v4";
import Model from 'mdeditor/models/base';
import {
validator,
Expand Down Expand Up @@ -85,7 +84,7 @@ const Record = Model.extend(Validations, Copyable, {
metadata: {
metadataInfo: {
metadataIdentifier: {
identifier: uuidV4(),
identifier: null,
namespace: 'urn:uuid'
},
metadataContact: [],
Expand Down Expand Up @@ -250,7 +249,7 @@ const Record = Model.extend(Validations, Copyable, {
json.set('metadata.resourceInfo.resourceType', getWithDefault(json,
'metadata.resourceInfo.resourceType', [{}]));
json.set('metadata.metadataInfo.metadataIdentifier', {
identifier: uuidV4(),
identifier: null,
namespace: 'urn:uuid'
});

Expand Down
5 changes: 2 additions & 3 deletions app/pods/components/control/md-modal/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export default Component.extend({
* @method cancel
*/
cancel() {
console.log('cancel')
this.closeModal();
},

Expand Down Expand Up @@ -121,6 +120,6 @@ export default Component.extend({
*/
cancel() {
this.cancel();
}
}
},
},
});
Loading

0 comments on commit 7f076e3

Please sign in to comment.