-
-
Notifications
You must be signed in to change notification settings - Fork 8
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 edit functionality for notes #101
base: main
Are you sure you want to change the base?
Changes from 1 commit
2c9c890
1549bbb
ffb6227
55b2ea8
4c63b6d
85a6f40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,19 +2,53 @@ | |
|
||
<% unless notes.empty? %> | ||
<h3>Notes</h3> | ||
<% notes.each do |note| %> | ||
<div class="box"> | ||
<div class="columns is-full"> | ||
<div class="column"> | ||
<h4 class="mb-0"><%= note.body %></h4> | ||
<small>Created at: <%= note.created_at %></small> | ||
|
||
<% notes.each do |note| %> | ||
<div class="box p-0" style="border: 1px solid #1c1c39"> | ||
<div class="columns m-0 p-1" style="background-color: #1c1c39"> | ||
<div class="column is-half px-3 py-0"> | ||
<small class="is-size-7">Created at: <%= note.created_at %></small> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably safe, but I'd escape the timestamp using |
||
</div> | ||
|
||
<div class="column has-text-right p-0 pr-1 mt-0"> | ||
<div class="dropdown three-dots is-right"> | ||
<div class="dropdown-trigger"> | ||
<span class="icon is-small"> | ||
<i class="fas fa-ellipsis-h"></i> | ||
</span> | ||
</div> | ||
<div class="dropdown-menu" id="dropdown-menu6" role="menu"> | ||
<div class="dropdown-content"> | ||
<a class="dropdown-item py-2 edit-note" data-note-id=<%= note.id %>>Edit</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably a good idea to escape |
||
<a class="dropdown-item py-2 delete-note has-text-danger" data-note-id=<%= note.id %>>Delete</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably a good idea to escape |
||
</div> | ||
</div> | ||
</div> | ||
<div class="column is-one-fifth has-text-right"> | ||
<button class="button is-danger is-small delete-note " data-note-id=<%= note.id %>>X</button> | ||
</div> | ||
</div> | ||
|
||
<div class="columns is-full"> | ||
<div class="column"> | ||
<div id="note-edit-body-<%= note.id %>" class="mb-0 p-4"><%= note.body %></div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably a good idea to escape |
||
|
||
<div id="note-edit-form-<%= note.id %>" style="display: none"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably a good idea to escape |
||
<div class="control"> | ||
<div class="media-content"> | ||
<div class="field mb-0 p-2"> | ||
<textarea id="note-edit-textarea-<%= note.id %>" class="textarea" name="body" placeholder="Edit a note..."><%= note.body %></textarea> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably a good idea to escape |
||
</div> | ||
|
||
<div class="field is-flex is-justify-content-flex-end px-2 pb-2"> | ||
<button class="edit-note button is-small is-danger mr-2" data-note-id=<%= note.id %>>Discard</button> | ||
<button class="update-note button is-small is-primary" data-note-id=<%= note.id %> data-note-body=<%= note.body %>>Save</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Attributes need |
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
|
||
<div class="control mt-4"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
<link rel="stylesheet" type="text/css" media="screen" href="/stylesheets/bulma.min.css" /> | ||
<link rel="stylesheet" type="text/css" media="screen" href="/stylesheets/app.css" /> | ||
<script type="text/javascript" src="/javascript/app.js"></script> | ||
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not add a font just yet and use the browser's default font, especially not some external JavaScript asset font. The whole app should be able to load and run without an internet connection. |
||
</head> | ||
|
||
<body> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would return a different error code if the
update
fails, like400
(Bad Request).