Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding unique name index on groups collection #451

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/both/collections/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ var GroupsSchema = new SimpleSchema({

Groups.attachSchema(GroupsSchema);

Meteor.startup(()=>{
Groups._ensureIndex({ name: 1 }, { unique: true });
})

Groups.helpers({
'homes': function () {
// Get group ID
Expand Down
12 changes: 9 additions & 3 deletions app/client/views/groups/modal/autoform.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ AutoForm.addHooks(['groupForm'], {
onSuccess: function() {
// Hide the modal dialogue
Modal.hide('newGroup');
FlashMessages.clear();
},
onError: function(formType, error) {
FlashMessages.sendError('<i class="fa fa-warning"></i> ' + error.message, {
onError: function(formType, errorObj) {
const { error } = errorObj;
let message = errorObj.message;

if (error === 500) {
message = TAPi18n.__('homes-addNewGroup-duplicateName-errorMessage');
}

FlashMessages.sendError('<i class="fa fa-warning"></i> ' + message, {
autoHide: true,
hideDelay: 3000
});
Expand Down
1 change: 1 addition & 0 deletions app/lib/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"homes-header": "Homes",
"users-deactivateOn-label": "Deactivate on",
"homes-header-addNewButton-group": "Add Group",
"homes-addNewGroup-duplicateName-errorMessage": "Error creating data. Make sure the group name is not duplicated.",
"homes-homeGroup-addNewButton-home": "Add Home",
"homes-homeGroup-assignManagerButton-home": "Assign Manager",
"noDataToDisplay": "No data to display",
Expand Down