-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from fleetbase/dev-v0.1.10
v0.1.10
- Loading branch information
Showing
27 changed files
with
162 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,109 @@ | ||
import ExtensionModel from '@fleetbase/console/models/extension'; | ||
import { attr } from '@ember-data/model'; | ||
import Model, { attr, belongsTo } from '@ember-data/model'; | ||
import { computed, action } from '@ember/object'; | ||
import { format as formatDate, formatDistanceToNow, isValid as isValidDate } from 'date-fns'; | ||
|
||
export default class OrderConfigModel extends ExtensionModel { | ||
@attr('string') install_uuid; | ||
@attr('boolean') installed; | ||
export default class OrderConfigModel extends Model { | ||
/** @ids */ | ||
@attr('string') company_uuid; | ||
@attr('string') author_uuid; | ||
@attr('string') category_uuid; | ||
@attr('string') icon_uuid; | ||
|
||
/** @relationships */ | ||
@belongsTo('user') author; | ||
@belongsTo('category') category; | ||
@belongsTo('file') icon; | ||
|
||
/** @attributs */ | ||
@attr('string') name; | ||
@attr('string') namespace; | ||
@attr('string') description; | ||
@attr('string') key; | ||
@attr('string') status; | ||
@attr('string') version; | ||
@attr('boolean', { defaultValue: false }) core_service; | ||
@attr('array') tags; | ||
@attr('object') flow; | ||
@attr('object') entities; | ||
@attr('object') meta; | ||
|
||
/** @computed */ | ||
@computed('updated_at') get updatedAgo() { | ||
if (!isValidDate(this.updated_at)) { | ||
return null; | ||
} | ||
|
||
return formatDistanceToNow(this.updated_at); | ||
} | ||
|
||
@computed('updated_at') get updatedAt() { | ||
if (!isValidDate(this.updated_at)) { | ||
return null; | ||
} | ||
|
||
return formatDate(this.updated_at, 'PP HH:mm'); | ||
} | ||
|
||
@computed('updated_at') get updatedAtShort() { | ||
if (!isValidDate(this.updated_at)) { | ||
return null; | ||
} | ||
|
||
return formatDate(this.updated_at, 'dd, MMM'); | ||
} | ||
|
||
@computed('created_at') get createdAgo() { | ||
if (!isValidDate(this.created_at)) { | ||
return null; | ||
} | ||
|
||
return formatDistanceToNow(this.created_at); | ||
} | ||
|
||
@computed('created_at') get createdAt() { | ||
if (!isValidDate(this.created_at)) { | ||
return null; | ||
} | ||
|
||
return formatDate(this.created_at, 'PP HH:mm'); | ||
} | ||
|
||
@computed('created_at') get createdAtShort() { | ||
if (!isValidDate(this.created_at)) { | ||
return null; | ||
} | ||
|
||
return formatDate(this.created_at, 'dd, MMM'); | ||
} | ||
|
||
/** @methods */ | ||
/** | ||
* Adds a new tag to the tags array. | ||
* | ||
* This method takes a tag and adds it to the 'tags' array property | ||
* of the current instance. The 'pushObject' method is used, which is | ||
* typically available in Ember.js or similar frameworks that extend | ||
* JavaScript array functionalities. | ||
* | ||
* @param {string} tag - The tag to be added to the tags array. | ||
*/ | ||
@action addTag(tag) { | ||
this.tags.push(tag); | ||
this.tags = [...this.tags]; | ||
} | ||
|
||
/** | ||
* Removes a tag from the tags array at a specific index. | ||
* | ||
* This method takes an index and removes the element at that position | ||
* from the 'tags' array property of the current instance. The 'removeAt' | ||
* method is used, which is typically available in Ember.js or similar | ||
* frameworks that provide extended array functionalities. | ||
* | ||
* @param {number} index - The index of the tag to be removed from the tags array. | ||
*/ | ||
@action removeTag(index) { | ||
this.tags.removeAt(index); | ||
this.tags = [...this.tags]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.