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

List Notes and add Add note button. #59

Merged
merged 6 commits into from
Nov 6, 2023

Conversation

AI-Mozi
Copy link
Member

@AI-Mozi AI-Mozi commented Nov 3, 2023

@AI-Mozi
Copy link
Member Author

AI-Mozi commented Nov 3, 2023

Need to find out why deleting comments returns 500 sometimes. Not sure if its related to my machine only or not.

@postmodern
Copy link
Member

Those 500 errors might be related to #16, which I thought I fixed by setting the ActiveRecord connection pool size.

Copy link
Member

@postmodern postmodern left a comment

Choose a reason for hiding this comment

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

Some light feedback.

app.rb Outdated
if @record.notes.create!(body: params[:body])
flash[:success] = "Note added successfully."
else
flash[:danger] = "Something went wrong!"
Copy link
Member

Choose a reason for hiding this comment

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

Change message to "Failed to create Note".


<%= partial(:notes, notes: @advisory.notes) %>

<%= partial(:add_note, parent: @advisory) %>
Copy link
Member

Choose a reason for hiding this comment

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

You could probably merge _add_note.erb into _notes.erb.

views/_notes.erb Outdated
console.error('Error:', error);
});
}
</script>
Copy link
Member

Choose a reason for hiding this comment

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

This JavaScript should probably be extracted into public/javascript/notes.js so it gets cached by the browser.

views/_notes.erb Outdated
@@ -0,0 +1,43 @@
<% if notes.present? %>
Copy link
Member

Choose a reason for hiding this comment

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

Use unless notes.empty?. I'm trying to avoid using ActiveSupport core-exts as much as possible. In the future I may switch from ActiveRecord to Sequel::Model.

views/_notes.erb Outdated
console.error('Error:', error);
});
}
</script>
Copy link
Member

Choose a reason for hiding this comment

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

Also this JavaScript should be wrapped in a function that is passed to ready(...);.

const Notes = {
  init() {
    ...
  },

  delete(noteId, button) {
    ...
  }
};

ready(Notes.init);

views/_notes.erb Outdated

<script>
const deleteButtons = document.querySelectorAll('.delete-note');
const path = '<%= request.path_info %>'
Copy link
Member

Choose a reason for hiding this comment

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

Could we use document.location?

@AI-Mozi AI-Mozi marked this pull request as ready for review November 4, 2023 17:17
views/_notes.erb Outdated
<% end %>
<% end %>

<%= partial(:add_note) %>
Copy link
Member

Choose a reason for hiding this comment

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

I would just merge _add_note.erb directly into _notes.erb. I don't think you'd ever want to render _add_note.erb separately from _notes.erb?

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right.

views/_notes.erb Outdated
</div>
</form>
</div>

Copy link
Member

Choose a reason for hiding this comment

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

Trailing newline.

@postmodern postmodern merged commit a09746f into ronin-rb:main Nov 6, 2023
3 checks passed
@postmodern postmodern added the feature New Feature label Dec 4, 2023
@postmodern postmodern added this to the 0.1.0 milestone Dec 4, 2023
@postmodern postmodern added the views Views label Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New Feature views Views
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants