Skip to content

Commit

Permalink
🐛 fixed some glitches with the project color edit feature
Browse files Browse the repository at this point in the history
🐛 fixed a bug in the Details view which prevented selecting both a 
customer and a project
  • Loading branch information
faburem committed Sep 12, 2019
1 parent b4acf3b commit fcb3d56
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
30 changes: 16 additions & 14 deletions imports/ui/pages/editproject.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,13 @@ Template.editproject.onCreated(function editprojectSetup() {
})
this.wekanLists = new ReactiveVar()
})
Template.editproject.onRendered(function editprojectRendered() {
Template.editproject.onRendered(() => {
const templateInstance = Template.instance()
if (!FlowRouter.getParam('id')) {
templateInstance.color = `#${(`000000${Math.floor(0x1000000 * Math.random()).toString(16)}`).slice(-6)}`
$('#color').val(templateInstance.color)
}
templateInstance.pickr = Pickr.create({
const pickrOptions = {
el: '#pickr',
theme: 'monolith',
lockOpacity: true,
comparison: false,
default: templateInstance.color,
position: 'left-start',
components: {
preview: true,
Expand All @@ -73,18 +68,24 @@ Template.editproject.onRendered(function editprojectRendered() {
save: false,
},
},
})
templateInstance.pickr.on('change', (color, instance) => {
}
if (!FlowRouter.getParam('id')) {
templateInstance.color = `#${(`000000${Math.floor(0x1000000 * Math.random()).toString(16)}`).slice(-6)}`
$('#color').val(templateInstance.color)
pickrOptions.default = templateInstance.color
}
templateInstance.pickr = Pickr.create(pickrOptions)
templateInstance.pickr.on('change', (color) => {
$('#color').val(color.toHEXA().toString())
})
import('quill').then((quillImport) => {
import('quill/dist/quill.snow.css')
templateInstance.quill = new quillImport.default('#richDesc', {
theme: 'snow',
})
if (Projects.findOne().desc instanceof Object && templateInstance.quill) {
if (Projects.findOne() && Projects.findOne().desc instanceof Object && templateInstance.quill) {
templateInstance.quill.setContents(Projects.findOne().desc)
} else if (Projects.findOne().desc && templateInstance.quill) {
} else if (Projects.findOne() && Projects.findOne().desc && templateInstance.quill) {
templateInstance.quill.setText(Projects.findOne().desc)
}
})
Expand All @@ -93,7 +94,7 @@ Template.editproject.onRendered(function editprojectRendered() {
if (templateInstance.handle && templateInstance.handle.ready()) {
if (Projects.findOne()) {
templateInstance.pickr.setColor(Projects.findOne().color
? Projects.findOne().color : this.color)
? Projects.findOne().color : templateInstance.color)
if (Projects.findOne().desc instanceof Object && templateInstance.quill) {
templateInstance.quill.setContents(Projects.findOne().desc)
} else if (Projects.findOne().desc && templateInstance.quill) {
Expand Down Expand Up @@ -155,7 +156,7 @@ Template.editproject.events({
},
'click #addNewMember': (event) => {
event.preventDefault()
const emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
const emailRegex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
const newmembermail = $('#newmembermail').val()
if (newmembermail && emailRegex.test(newmembermail)) {
Meteor.call('addTeamMember', { projectId: FlowRouter.getParam('id'), eMail: $('#newmembermail').val() }, (error, result) => {
Expand Down Expand Up @@ -227,6 +228,7 @@ Template.editproject.events({
}
},
'change #wekanurl': (event) => {
event.preventDefault()
validateWekanUrl()
},
'click #wekan-status': (event) => {
Expand All @@ -252,6 +254,6 @@ Template.editproject.helpers({
},
projectId: () => FlowRouter.getParam('id'),
disablePublic: () => Meteor.settings.public.disablePublic,
archived: _id => (Projects.findOne({ _id }) ? Projects.findOne({ _id }).archived : false),
archived: (_id) => (Projects.findOne({ _id }) ? Projects.findOne({ _id }).archived : false),
target: () => (Projects.findOne() ? Projects.findOne().target : false),
})
9 changes: 4 additions & 5 deletions imports/ui/pages/timecardlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,19 @@ Template.timecardlist.onDestroyed(() => {
Template.timecardlist.helpers({
selector() {
const returnSelector = {}
if (Template.instance().project.get() !== 'all') {
returnSelector.projectId = Template.instance().project.get()
}
if (Template.instance().resource.get() !== 'all') {
returnSelector.userId = Template.instance().resource.get()
}
if (Template.instance().customer.get() !== 'all') {
if (Template.instance().project.get() !== 'all') {
returnSelector.projectId = Template.instance().project.get()
} else if (Template.instance().customer.get() !== 'all') {
const projectList = Projects.find(
{
customer: Template.instance().customer.get(),
$or: [{ userId: Meteor.userId() }, { public: true }, { team: Meteor.userId() }],
},
{ $fields: { _id: 1 } },
).fetch().map(value => value._id)
).fetch().map((value) => value._id)
returnSelector.projectId = { $in: projectList }
}
if (Template.instance().period.get() !== 'all') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "titra",
"version": "0.6.1",
"version": "0.6.2",
"private": true,
"scripts": {
"start": "meteor run"
Expand Down

0 comments on commit fcb3d56

Please sign in to comment.