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

Add task notes first attempt #72

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 0 additions & 1 deletion nodejs/listeners/views/newTaskModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions nodejs/migrations/20210715225839-add-task-notes.js
Original file line number Diff line number Diff line change
@@ -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',
),
};
2 changes: 2 additions & 0 deletions nodejs/models/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ module.exports = (sequelize, DataTypes) => {
},
dueDate: DataTypes.DATE,
scheduledMessageId: DataTypes.STRING,
// Unsure if this is necessary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You definitely need this

notes: DataTypes.STRING,
},
{
sequelize,
Expand Down
31 changes: 29 additions & 2 deletions nodejs/user-interface/app-home/open-tasks-view.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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
Comment on lines +37 to +55
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this is just the old code, so not looking at it.


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()}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is :spiral_calendar_pad: part of the standard emoji set? e.g. does it render on all workspaces?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
option.description = `:spiral_calendar_pad: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`})])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's two things here, which maybe because you haven't fully written out your thoughts, but as written

  • There's nothing happening with the Context(). You're not assigning it to anything, or trying to embed it into anything. It's like a fragment of a sentence in the middle of a story.
  • I don't think you can use a Context block as an option inside an input block. You'd need to have it after the input block, which will make the list render funny.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I did some digging in the BlockBuilder source code and I think I have it.

      Context({}).elements(['Foo', 'Bar']),

return Bits.Option(option);
}))),
);
}

homeTab.blocks(
Header({ text: `You have ${openTasks.length} open ${pluralize('task', openTasks.length)}` }),
Divider(),
Expand Down
7 changes: 7 additions & 0 deletions nodejs/user-interface/modals/new-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you pick 300 at random or was their a specific reason for it?

})
.multiline(true),
),
).buildToJSON();
};