-
Notifications
You must be signed in to change notification settings - Fork 37
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
Fix/subject keywords #5687
base: develop
Are you sure you want to change the base?
Fix/subject keywords #5687
Conversation
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.
Attempting to add a keyword results in a POST request to http://localhost:8000/hsapi/_internal/undefined/subject/add-metadata/
☝️ your code is not correctly identifying the resIdShort
if(newKWLength > 500){ | ||
this.newKeyword = this.newKeyword.slice(0, -1); | ||
event.preventDefault(); | ||
this.error = "Warning: You have exceeded the character 500 character limit for the subject keywords field. In a future release you will be unable to continue adding keywords beyond the 500 character limit"; |
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.
you need to update this message to match the one that Clara suggested here:
#5638 (comment)
|
||
if element_name.lower() == "subject": | ||
original_value = request.POST.get("value", "") | ||
keywords = original_value.replace(",", "") | ||
# Make request.POST mutable | ||
mutable_post = request.POST.copy() | ||
mutable_post["value"] = keywords | ||
request.POST = mutable_post | ||
|
||
handler_response = signals.pre_metadata_element_create.send( | ||
sender=sender_resource, element_name=element_name, request=request | ||
) | ||
|
||
if element_name.lower() == "subject" and original_value: | ||
mutable_post["value"] = original_value # Reassign original value | ||
request.POST = mutable_post | ||
|
||
for receiver, response in handler_response: | ||
if "is_valid" in response: | ||
if response["is_valid"]: | ||
element_data_dict = response["element_data_dict"] | ||
|
||
if element_name == "subject": | ||
if original_value: | ||
element_data_dict["value"] = original_value | ||
|
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.
It looks here like you're trying to handle comma delimited entries.
I'm not convinced that you need to modify this __init__.py
file at all.
I think that if you modify your newKeywordsLength
function so that it is accurate, you can remove all of the modifications that you are making here.
newKeywordsLength: function () { | ||
let newVal = this.resKeywords.join("") + this.newKeyword; | ||
return newVal.length; | ||
} |
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.
newKeywordsLength: function () { | |
let newVal = this.resKeywords.join("") + this.newKeyword; | |
return newVal.length; | |
} | |
newKeywordsLength: function () { | |
let newVal = this.resKeywords.join(",") + this.newKeyword; | |
return newVal.length; | |
} |
☝️ perhaps this will give you a more accurate count of the KW length?
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.
So, is 500 characters limit including comma ? I thought the 500 char limit is without including comma. @devincowan
Pull Request Checklist:
Positive Test Case