diff --git a/nodejs/listeners/views/newTaskModal.js b/nodejs/listeners/views/newTaskModal.js index ea5dd45..0be27a2 100644 --- a/nodejs/listeners/views/newTaskModal.js +++ b/nodejs/listeners/views/newTaskModal.js @@ -73,7 +73,6 @@ module.exports = (app) => { await task.save(); await task.setCreator(user); await task.setCurrentAssignee(selectedUserObject); - if (task.dueDate) { const dateObject = DateTime.fromJSDate(task.dueDate); // The `chat.scheduleMessage` endpoint only accepts messages in the next 120 days, diff --git a/nodejs/migrations/20210715225839-add-task-notes.js b/nodejs/migrations/20210715225839-add-task-notes.js new file mode 100644 index 0000000..f7360b3 --- /dev/null +++ b/nodejs/migrations/20210715225839-add-task-notes.js @@ -0,0 +1,15 @@ +module.exports = { + up: async (queryInterface, Sequelize) => queryInterface.addColumn( + 'Tasks', + 'notes', + { + type: Sequelize.STRING, + allowNull: true, + }, + ), + + down: async (queryInterface) => queryInterface.removeColumn( + 'Tasks', + 'notes', + ), +}; diff --git a/nodejs/models/task.js b/nodejs/models/task.js index 61b61cb..04b72c3 100644 --- a/nodejs/models/task.js +++ b/nodejs/models/task.js @@ -24,6 +24,8 @@ module.exports = (sequelize, DataTypes) => { }, dueDate: DataTypes.DATE, scheduledMessageId: DataTypes.STRING, + // Unsure if this is necessary + notes: DataTypes.STRING, }, { sequelize, diff --git a/nodejs/user-interface/app-home/open-tasks-view.js b/nodejs/user-interface/app-home/open-tasks-view.js index 3e24456..1d4d4c3 100644 --- a/nodejs/user-interface/app-home/open-tasks-view.js +++ b/nodejs/user-interface/app-home/open-tasks-view.js @@ -1,5 +1,6 @@ +// added Blocks and Context blocks const { - HomeTab, Header, Divider, Section, Actions, Elements, Input, Bits, + HomeTab, Header, Divider, Section, Actions, Elements, Input, Bits, Context, Blocks, } = require('slack-block-builder'); const pluralize = require('pluralize'); const { DateTime } = require('luxon'); @@ -33,21 +34,47 @@ module.exports = (openTasks) => { const end = openTasks.length; const maxOptionsLength = 10; + // LEAVING THIS UNTOUCHED FOR NOW + + // for (start, end; start < end; start += maxOptionsLength) { + // holdingArray = openTasks.slice(start, start + maxOptionsLength); + // tasksInputsArray.push( + // Input({ label: ' ', blockId: `open-task-status-change-${start}` }).dispatchAction().element(Elements.Checkboxes({ actionId: 'blockOpenTaskCheckboxClicked' }).options(holdingArray.map((task) => { + // const option = { + // text: `*${task.title}*`, + // value: `open-task-${task.id}`, + // }; + // if (task.dueDate) { + // option.description = `Due ${DateTime.fromJSDate(task.dueDate).toRelativeCalendar()}`; + // } + // return Bits.Option(option); + // }))), + // ); + // } + + // SANDRA TESTING + for (start, end; start < end; start += maxOptionsLength) { holdingArray = openTasks.slice(start, start + maxOptionsLength); tasksInputsArray.push( Input({ label: ' ', blockId: `open-task-status-change-${start}` }).dispatchAction().element(Elements.Checkboxes({ actionId: 'blockOpenTaskCheckboxClicked' }).options(holdingArray.map((task) => { + // Below adding a context block as a variable and passed it Bits.Option + // let context = Blocks.Context().elements([Elements.TextInput({text:"this is a context block"})],[Elements.TextInput({text:"this is another context block"})]) const option = { text: `*${task.title}*`, value: `open-task-${task.id}`, }; if (task.dueDate) { - option.description = `Due ${DateTime.fromJSDate(task.dueDate).toRelativeCalendar()}`; + option.description = `:spiral_calendar_pad:Due ${DateTime.fromJSDate(task.dueDate).toRelativeCalendar()}`; } + // Tried adding this line with some hardcoded text for each element but that didn't work either. + // I don't think TextInput can be passed in .elements but if that's the case documentation does not show how add mrkdwn elements to a Context block? + // Context().elements([Elements.TextInput({text:`something`})],[Elements.TextInput({text:`something else`})]) return Bits.Option(option); }))), ); } + homeTab.blocks( Header({ text: `You have ${openTasks.length} open ${pluralize('task', openTasks.length)}` }), Divider(), diff --git a/nodejs/user-interface/modals/new-task.js b/nodejs/user-interface/modals/new-task.js index bc058be..c88180e 100644 --- a/nodejs/user-interface/modals/new-task.js +++ b/nodejs/user-interface/modals/new-task.js @@ -35,5 +35,12 @@ module.exports = (prefilledTitle, currentUser) => { actionId: 'taskDueTime', }), ), + Blocks.Input({ label: 'Notes', blockId: 'taskNotes', optional: true }).element( + Elements.TextInput({ + actionId: 'taskNotes', + maxLength: 300, + }) + .multiline(true), + ), ).buildToJSON(); };