-
Notifications
You must be signed in to change notification settings - Fork 72
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
卒業証書のPDFファイルをアップロードできる機能を追加 #8190
base: main
Are you sure you want to change the base?
Changes from 1 commit
496b8ec
8385b8a
3d8dc4e
f3bc5cc
d16a661
fd1d8db
b2ff53d
3aeb25a
6b5d653
9b55b38
7d82332
97b19ed
ba692b1
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 |
---|---|---|
|
@@ -85,3 +85,17 @@ document.addEventListener('DOMContentLoaded', () => { | |
} | ||
initializeFileInput(document) | ||
}) | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const removeDiplomaButton = document.getElementById('remove-diploma-button') | ||
const diplomaUploadField = document.getElementById('diploma-upload-field') | ||
const diplomaFileLink = document.getElementById('diploma-file-link') | ||
const removeDiplomaFlag = document.getElementById('remove-diploma-flag') | ||
|
||
removeDiplomaButton.addEventListener('click', () => { | ||
diplomaFileLink && (diplomaFileLink.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. すみません、ここの説明ほしいです🙏 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. 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. diplomaFileLinkが存在する場合のみ右辺が発火するわけですね。 その場合下記のような形ではどうでしょうか? if (diplomaFileLink) diplomaFileLink.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. 町田さんがデザインを入れた際に変更してくれたみたいです🤔18c14ab2e02b8526752 |
||
diplomaUploadField.style.display = 'block' | ||
diplomaUploadField.value = '' | ||
removeDiplomaFlag.value = '1' | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,15 @@ | |
.form-item-block__item | ||
= render 'users/form/graduate', f: f | ||
|
||
.form-item | ||
= f.hidden_field :remove_diploma, value: '0', id: 'remove-diploma-flag' | ||
= f.label :diploma_file, class: 'a-form-label' | ||
- if @user.diploma_file.attached? | ||
= link_to @user.diploma_file.filename, url_for(@user.diploma_file), class: 'a-text-input', id: 'diploma-file-link' | ||
- display = @user.diploma_file.attached? ? 'display: none' : 'display: block' | ||
= f.file_field :diploma_file, class: 'a-text-input', id: 'diploma-upload-field', style: display | ||
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.
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. そちらの名前の方がわかりやすいですね。変更しました! |
||
button type='button' id='remove-diploma-button' class='a-button is-md is-secondary' 削除 | ||
|
||
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. button_tagが使えそうです! 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. 変更しました 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. ファイルがアップロードされていない状態で削除ボタンがあるのはおかしい気がします🤔 |
||
.form-item-block | ||
.form-item-block__inner | ||
header.form-item-block__header | ||
|
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.
今回実装する部分を関数にして↑の DOMContentLoadedに入れてはどうでしょうか?
あと画面の読み込み時に実行していますが、該当する画面でない場合のreturnがなさそうです。
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.
変更しました
6b5d653