-
Notifications
You must be signed in to change notification settings - Fork 111
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
Fixes to edit script javascript #3095
Conversation
function lastOption() { | ||
return $('.new_script').find('.editable-form-field').last(); | ||
function addNewFieldButton() { | ||
return $('#add_new_field_button'); | ||
} |
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.
This is the fix to support deleting all editable fields from the form.
74f01ca
to
4c2b74d
Compare
apps/dashboard/app/models/script.rb
Outdated
@@ -152,6 +152,7 @@ def destroy | |||
end | |||
|
|||
def update(params) | |||
params ||= {} |
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.
Not sure why this is here - Rails should always populate params. In any case I think params
is a HashWithIndifferentAccess
which could be important in case we're using strings and symbols here and there.
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.
When all form fields are removed from the edit script page and then the form is submitted, the application will throw a null pointer and show the stacktrace on the screen. When there are no fields on the form, params is nil
in update.
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.
# ScriptsController#51
@script.update(save_script_params[:script])
save_script_params[:script]
will return nil when the form is empty
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.
When all form fields are removed from the edit script page and then the form is submitted
I haven't looked this over in detail quite yet - but you shouldn't be able to remove all fields. You need at least auto_script
.
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.
OK - at the moment you can. I will revert this and take a look to disable deleting auto_scripts
from the form.
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.
Fixed
4c2b74d
to
45fca40
Compare
def script_remove_field_enabled(id) | ||
!['script_auto_scripts'].include?(id.to_s) | ||
end |
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.
Can you change this to a question like removable?
or removable_field?
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.
updated
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.
Looks good, thanks!
One final thing @johrstrom, should we disable deleting It seems that even if deleted, it appears again in the show and edit views. |
No. To submit a job you need a script to submit and a scheduler to submit it to. That's across all schedulers and systems. At OSC you'd also need to specify an account - so we probably need a ticket to make required items configurable. But without a script to run or a cluster to submit it to - nothing can happen. |
Sorry @johrstrom, I am not sure I am not reading your comment correctly. We removed the "Remove" button from |
Sorry the double logic of |
Fixes to the edit script javascript functionality:
Add new option
button while there is one in progress.Add new option
button if no more fields to add.