Skip to content

Commit 8788217

Browse files
committed
component for tag creation
1 parent 451053a commit 8788217

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

app/pods/components/question-editor/component.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { inject as service } from '@ember/service';
33
import { task, timeout } from 'ember-concurrency';
44

55
export default Component.extend({
6+
currentUser: service(),
67
store: service(),
78
api: service(),
89
notify: service(),
@@ -60,8 +61,18 @@ export default Component.extend({
6061
}).then(() => {
6162
this.set('correctChoices', [...correctChoices])
6263
})
63-
64+
},
65+
createNewTag() {
66+
const onSuccess = () => this.get('notify').success('New Tag Created')
67+
68+
let newTag = this.store.createRecord('tag', {
69+
title: this.get('tagTitle'),
70+
})
6471

72+
newTag.set('user', this.get('currentUser.user'))
73+
console.log(newTag.user)
74+
newTag.save()
75+
.then(onSuccess)
6576
}
6677
}
6778
});

app/pods/components/question-editor/template.hbs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,20 @@
6565
{{/power-select-multiple}}
6666
</div>
6767
</div>
68-
68+
<div class="row"></div>
69+
<div class="row justify-content-center align-items-center">
70+
<div class="col-2">
71+
<label>Create New Tag: </label>
72+
</div>
73+
<div class="col-5 input-group">
74+
{{input type="text" class="input-text" placeholder="Enter Tag's Title" value=tagTitle}}
75+
</div>
76+
<div class="col-5">
77+
<span {{action 'createNewTag'}}>
78+
Save
79+
<i class="far fa-save"></i>
80+
</span></div>
81+
</div>
6982
Created By: <mark>{{question.user.firstname}}</mark>
7083

7184
{{/unless}}

0 commit comments

Comments
 (0)