From a3af648e436f59a936515e742f0b5ae338fb9289 Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Wed, 24 Jun 2020 17:10:54 -0400 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20Add=20new=20group=20vie?= =?UTF-8?q?w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/core/app/components/form/group/index.hbs | 49 +++++++++++++++++++ ui/core/app/routes/orgs/org/groups/new.js | 46 +++++++++++++++++ ui/core/app/templates/orgs/org/groups/new.hbs | 14 +++++- ui/core/translations/en-us.yaml | 2 + 4 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 ui/core/app/components/form/group/index.hbs diff --git a/ui/core/app/components/form/group/index.hbs b/ui/core/app/components/form/group/index.hbs new file mode 100644 index 000000000..9db695baa --- /dev/null +++ b/ui/core/app/components/form/group/index.hbs @@ -0,0 +1,49 @@ + + + + {{#if @model.errors.name}} + + {{#each @model.errors.name as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + {{#if @model.errors.description}} + + {{#each @model.errors.description as |error|}} + {{error.message}} + {{/each}} + + {{/if}} + + + + + diff --git a/ui/core/app/routes/orgs/org/groups/new.js b/ui/core/app/routes/orgs/org/groups/new.js index b784e95aa..6f353d368 100644 --- a/ui/core/app/routes/orgs/org/groups/new.js +++ b/ui/core/app/routes/orgs/org/groups/new.js @@ -1,4 +1,50 @@ import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; +import { action } from '@ember/object'; export default class OrgsOrgGroupsNewRoute extends Route { + // =services + + @service intl; + @service notify; + + // =methods + + /** + * Returns a new unsaved group. + * @return {Promise{GroupModel}} + */ + model() { + return this.store.createRecord('group'); + } + + // =actions + + /** + * Rollback changes on group by destroying unsaved instance + * and redirect to group index. + * @param {GroupModel} group + */ + @action + cancel(group) { + group.rollbackAttributes(); + this.transitionTo('orgs.org.groups'); + } + + /** + * Handle saving a group. + * @param {GroupModel} group + * @param {Event} e + */ + @action + async save(group) { + try { + await group.save(); + this.transitionTo('orgs.org.groups.group', group); + this.notify.success(this.intl.t('notify.group.create-success')); + } catch (error) { + // TODO: replace with translated strings + this.notify.error(error.message, { closeAfter: null }); + } + } } diff --git a/ui/core/app/templates/orgs/org/groups/new.hbs b/ui/core/app/templates/orgs/org/groups/new.hbs index e2147cab0..d2b85b3a2 100644 --- a/ui/core/app/templates/orgs/org/groups/new.hbs +++ b/ui/core/app/templates/orgs/org/groups/new.hbs @@ -1 +1,13 @@ -{{outlet}} \ No newline at end of file + + +

{{t "titles.new"}}

+
+ + + + +
diff --git a/ui/core/translations/en-us.yaml b/ui/core/translations/en-us.yaml index 2498e9983..ab1aaf9c4 100644 --- a/ui/core/translations/en-us.yaml +++ b/ui/core/translations/en-us.yaml @@ -59,6 +59,8 @@ notify: role: create-success: Role created succesfully. delete-success: Deleted role successfully. + group: + create-success: Group created succesfully. dev: default-org: Default Org menu-item: Menu item