Skip to content

Add note type for activities#1103

Open
Siem2l wants to merge 4 commits into
masterfrom
feat/notes-multiple-choice
Open

Add note type for activities#1103
Siem2l wants to merge 4 commits into
masterfrom
feat/notes-multiple-choice

Conversation

@Siem2l
Copy link
Copy Markdown
Contributor

@Siem2l Siem2l commented May 31, 2024

I wondered how long it would take to implement this without altering too much in the database. I don’t think this is necessarily the best way to implement it, but it seems fully functional at least.

Only the translations are missing, I think.
image

image

Copy link
Copy Markdown
Contributor

@SanderHageman SanderHageman left a comment

Choose a reason for hiding this comment

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

Minor changes

Could only partially check because I can't read html/css and barely understand js and haml.

var par_notes;
var notes = [];
console.log(activity.has_notes_checkboxes);
if (activity.has_notes_checkboxes()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I also know little JS, however, does it not have switch cases?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any way to define the enum in 1 place like in activity.rb and reference it from the jabbascript?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Don't think so, atleast not trivally


@member = Member.find(current_user.credentials_id)
@notes = params[:par_notes]
@notes = params[:par_notes]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why did the linter add a double space? Linters 🤷

var notes = [];
console.log(activity.has_notes_checkboxes);
if (activity.has_notes_checkboxes()) {
console.log(this.notes.find(":checked"));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove log or cache this.notes call

Comment thread db/migrate/20240530151252_add_notes_input_type_to_activities.rb
Comment on lines +618 to +633
'<div class="col-md-12">' +
'<div class="input-group mb-3">' +
'<span class="input-group-text">Title</span>' +
'<input class="form-control" type="text" name="activity[notes_options][]">' +
"</div>" +
"</div>" +
'<div class="col-md-6">' +
'<div class="input-group mb-3">' +
'<input class="form-control" type="text" name="activity[notes_options][]">' +
'<div class="input-group-append">' +
'<button class="btn btn-sm btn-danger delete-option" type="button">' +
'<i class="fa fa-fw fa-minus"></i>' +
"</button>" +
"</div>" +
"</div>" +
"</div>";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps add some indentation here?

Copy link
Copy Markdown
Contributor Author

@Siem2l Siem2l Jun 5, 2024

Choose a reason for hiding this comment

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

Might be preferable, however, an even better approach would be to eliminate the need for generating HTML within the JavaScript code altogether.

Make a HAML partial file as a template for the option menu.
In the _edit haml file render the template but keep it hidden with css attributes
Update the code that appends the options HTML to use the cloned template.
Modify the code that sets the input values to target the cloned elements and make it visible
Add an event listener for the "Add Option" button to clone and append the template.
Add an event listener for the "Delete Option" button to remove the corresponding option.

this is not required, but would prevent coding twice when changing the UI

var activity = this;
var par_notes;
var notes = [];
console.log(activity.has_notes_checkboxes);
Copy link
Copy Markdown
Member

@SilasPeters SilasPeters Jun 4, 2024

Choose a reason for hiding this comment

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

Shouldn't the console log be removed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants