Skip to content

Commit

Permalink
fix(settings): tag display on no tags
Browse files Browse the repository at this point in the history
fix(model): to trim all name fields
  • Loading branch information
polonel committed Sep 20, 2018
1 parent b39719e commit 6929cc1
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 9 deletions.
6 changes: 6 additions & 0 deletions src/models/attachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ var attachmentSchema = mongoose.Schema({
type: { type: String, required: true }
});

attachmentSchema.pre('save', function(next) {
this.name = this.name.trim();

return next();
});

module.exports = attachmentSchema;
6 changes: 6 additions & 0 deletions src/models/notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ var noticeSchema = mongoose.Schema({
alertWindow:{ type: Boolean, default: false }
});

noticeSchema.pre('save', function(next) {
this.name = this.name.trim();

return next();
});

noticeSchema.statics.getNotices = function(callback) {
return this.model(COLLECTION).find({}).exec(callback);
};
Expand Down
3 changes: 2 additions & 1 deletion src/models/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ var tagSchema = mongoose.Schema({
});

tagSchema.pre('save', function(next) {
this.normalized = this.name.toLowerCase();
this.name = this.name.trim();
this.normalized = this.name.toLowerCase().trim();

return next();
});
Expand Down
2 changes: 2 additions & 0 deletions src/models/ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ var ticketSchema = mongoose.Schema({
ticketSchema.index({deleted: -1, group: 1, status: 1});

ticketSchema.pre('save', function(next) {
this.subject = this.subject.trim();

if (!_.isUndefined(this.uid) || this.uid)
return next();

Expand Down
6 changes: 6 additions & 0 deletions src/models/ticketpriority.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ var prioritySchema = mongoose.Schema({
}
});

prioritySchema.pre('save', function(next) {
this.name = this.name.trim();

return next();
});

prioritySchema.virtual('durationFormatted').get(function() {
var priority = this;
return moment.duration(priority.overdueIn, 'minutes').format('Y [year], M [month], d [day], h [hour], m [min]', {trim: 'both'});
Expand Down
6 changes: 6 additions & 0 deletions src/models/tickettype.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ var autoPopulatePriorities = function(next) {
ticketTypeSchema.pre('find', autoPopulatePriorities);
ticketTypeSchema.pre('findOne', autoPopulatePriorities);

ticketTypeSchema.pre('save', function(next) {
this.name = this.name.trim();

return next();
});

/**
* Return all Ticket Types
*
Expand Down
3 changes: 3 additions & 0 deletions src/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ userSchema.pre('save', function(next) {
var user = this;

user.username = user.username.trim();
user.title = user.title.trim();
user.email = user.email.trim();
user.fullname = user.fullname.trim();

if (!user.isModified('password'))
return next();
Expand Down
14 changes: 6 additions & 8 deletions src/public/js/angularjs/controllers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,10 @@ define(['angular', 'underscore', 'jquery', 'modules/helpers', 'modules/ui', 'uik
if (response.success) {
tags = response.tags;
// tags = [];
if (tags.length === 0)
$tagWrapper.append('<div><h3>No Tags Found</h3></div>');
else {
if (tags.length === 0) {
$tagWrapper.append('<div style="width: 100%; padding: 55px; text-align: center;"><h3 style="font-size: 24px; font-weight: 300;">No Tags Found</h3></div>');
$('.ticket-tags-pagination').hide();
} else {
tags.forEach(function(tag) {
var html = '';
html += '<div class="uk-width-1-2" style="border-right: 1px solid #ccc; border-bottom: 1px solid #ccc;">\n' +
Expand Down Expand Up @@ -330,10 +331,8 @@ define(['angular', 'underscore', 'jquery', 'modules/helpers', 'modules/ui', 'uik
$target.find('ul>li[data-key]').first().addClass('active');


if (settings === 'settings-legal') {
if (privacyPolicyMDE)
privacyPolicyMDE.codemirror.refresh();

if (settings === 'settings-legal' && privacyPolicyMDE) {
privacyPolicyMDE.codemirror.refresh();
}
}
}
Expand Down Expand Up @@ -1294,7 +1293,6 @@ define(['angular', 'underscore', 'jquery', 'modules/helpers', 'modules/ui', 'uik
priorities.forEach(function(p) {
if (p._id.toString() !== savedPriority._id)
html += '<option value="' + p._id + '">' + p.name + '</option>';

});

html +=
Expand Down

0 comments on commit 6929cc1

Please sign in to comment.