Skip to content

Commit

Permalink
feat(topic source editor): change aiTitle to previousTitle in editor …
Browse files Browse the repository at this point in the history
…interface, and make review state change to "edited" upon editing a topic prompt
  • Loading branch information
yonadavGit committed Feb 1, 2024
1 parent 72a86bd commit 2575e6d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions static/js/AdminEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const options_for_form = {
markdown: true
},
"Prompt": {label: "Source Description", field: "prompt", placeholder: "Add a prompt.", type: 'textarea'},
"AI Prompt": {label: "AI Source Description", field: "aiPrompt", placeholder: "AI Generated Prompt", type: 'textarea readonly'},
"Previous Prompt": {label: "Previous Source Description", field: "prompt", placeholder: "", type: 'textarea readonly'},
"Context for Prompt": {label: "Context for Prompt", field: "context", placeholder: "Why was this source added", type: 'textarea'},
"AI Title": {label: "AI Title", field: "aiTitle", placeholder: "AI Generated Title", type: 'readonly'},
"Previous Title": {label: "Previous Title", field: "enTitle", placeholder: "", type: 'readonly'},
"English Short Description": {
label: "English Short Description for Table of Contents", field: "enCategoryDescription",
placeholder: "Add a short description.", type: 'input'
Expand Down
14 changes: 7 additions & 7 deletions static/js/SourceEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ const SourceEditor = ({topic, close, origData={}}) => {
(origData.heRef || "") : (origData.ref || "") );
const title = Sefaria.interfaceLang === 'english' ? (origData?.descriptions?.en?.title || '') : (origData?.descriptions?.he?.title || '');
const prompt = Sefaria.interfaceLang === 'english' ? (origData?.descriptions?.en?.prompt || '') : (origData?.descriptions?.he?.prompt || '');
const aiPrompt = Sefaria.interfaceLang === 'english' ? (origData?.descriptions?.en?.ai_prompt || '') : (origData?.descriptions?.he?.ai_prompt || '');
const aiTitle = Sefaria.interfaceLang === 'english' ? (origData?.descriptions?.en?.ai_title || '') : (origData?.descriptions?.he?.ai_title || '');
// const aiPrompt = Sefaria.interfaceLang === 'english' ? (origData?.descriptions?.en?.ai_prompt || '') : (origData?.descriptions?.he?.ai_prompt || '');
// const aiTitle = Sefaria.interfaceLang === 'english' ? (origData?.descriptions?.en?.ai_title || '') : (origData?.descriptions?.he?.ai_title || '');
const context = Sefaria.interfaceLang === 'english' ? (origData?.descriptions?.en?.context || '') : (origData?.descriptions?.he?.context || '');

const [data, setData] = useState({enTitle: title, // use enTitle for hebrew or english case
prompt: prompt, aiPrompt: aiPrompt, aiTitle: aiTitle, context: context
prompt: prompt, context: context
});
const [changed, setChanged] = useState(false);
const [savingStatus, setSavingStatus] = useState(false);
Expand Down Expand Up @@ -51,7 +51,7 @@ const SourceEditor = ({topic, close, origData={}}) => {
let url = `/api/ref-topic-links/${Sefaria.normRef(refInUrl)}`;
let postData = {"topic": topic, "is_new": isNew, 'new_ref': displayRef, 'interface_lang': Sefaria.interfaceLang};
// if (data.enTitle.length > 0) {
postData['description'] = {"title": data.enTitle, "prompt": data.prompt, "context": data.context};
postData['description'] = {"title": data.enTitle, "prompt": data.prompt, "context": data.context, "review_state": "edited"};
// }
requestWithCallBack({url, data: postData, setSavingStatus, redirect: () => window.location.href = "/topics/"+topic});
}
Expand Down Expand Up @@ -94,11 +94,11 @@ const SourceEditor = ({topic, close, origData={}}) => {
requestWithCallBack({url, type: "DELETE", redirect: () => window.location.href = `/topics/${topic}`});
}
console.log(data)
let aiTitleItem = data.aiTitle ? "AI Title" : null
let aiPromptItem = data.aiPrompt ? "AI Prompt" : null
let previousTitleItem = data.enTitle ? "Previous Title" : null
let previousPromptItem = data.prompt ? "Previous Prompt" : null
return <div>
<AdminEditor title="Source Editor" close={close} data={data} savingStatus={savingStatus}
validate={validate} items={[aiTitleItem, "Title", aiPromptItem, "Prompt", "Context for Prompt"]} deleteObj={deleteTopicSource} updateData={updateData} isNew={isNew}
validate={validate} items={[previousTitleItem, "Title", previousPromptItem, "Prompt", "Context for Prompt"]} deleteObj={deleteTopicSource} updateData={updateData} isNew={isNew}
extras={
[<div>
<label><InterfaceText>Enter Source Ref (for example: 'Yevamot.62b.9-11' or 'Yevamot 62b:9-11')</InterfaceText></label>
Expand Down
2 changes: 1 addition & 1 deletion static/js/Story.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ const PromptWrapper = ({text}) => {
return promptComponent
}
const ReviewStateWrapper = ({topic, text}) => {
console.log(text)
let reviewIndicatorComponent = null;
const [reviewStateEn, setReviewStateEn] = useState(text.descriptions?.en?.review_state);
const [reviewStateHe, setReviewStateHe] = useState(text.descriptions?.he?.review_state);
Expand Down Expand Up @@ -213,7 +214,6 @@ const ReviewStateWrapper = ({topic, text}) => {

const IntroducedTextPassage = ({text, topic, afterSave, toggleSignUpModal, bodyTextIsLink=false}) => {
if (!text.ref) { return null; }
console.log(text)
const versions = text.versions || {}
const params = Sefaria.util.getUrlVersionsParams(versions);
const url = "/" + Sefaria.normRef(text.ref) + (params ? "?" + params : "");
Expand Down

0 comments on commit 2575e6d

Please sign in to comment.