Skip to content
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

[Help editor] Remove parentID #7025

Merged
merged 4 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ requesting a new account and will be displayed in the User Accounts module (PR #
#### Bug Fixes
- *Add item here*
### Modules
#### Help Editor
- parentID was removed. (PR #7025)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this changelog update means anything to users.

Copy link
Contributor Author

@laemtl laemtl Oct 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@driusan What do you suggest?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about a few more words to make it meaningful to readers, like :

Cleaned up deprecated column parentID #7025

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't think that means anything to readers. What's the effect of removing parentID? If it's not noticeable in any way, it's not worth mentioning in the changelog.

Copy link
Contributor Author

@laemtl laemtl Oct 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It affects the rendering of the data table, this change removes the column Parent Topic
Screenshot from 2020-10-05 15-22-21

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@driusan I edited the CHANGELOG to add @christinerogers suggestion, let me know if you prefer to remove the mention.

#### Issue Tracker
- Readability of comments and history was improved. (PR #6138)
#### Candidate Parameters
Expand Down Expand Up @@ -120,4 +122,4 @@ be used by projects having custom modules not in LORIS. (PR #5913)
- The tool `phpstan` has been added to our automated test suite. (PR #4928)
- Config files for static analysis have been moved to the `test/` directory. (PR #5871)
- Dashboard was refactored to turn panels into module widgets. (PR #5896)
- Add CSSGrid component type (PR #6090)
- Add CSSGrid component type (PR #6090)
1 change: 0 additions & 1 deletion SQL/0000-00-04-Help.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

CREATE TABLE `help` (
`helpID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`parentID` int(11) NOT NULL DEFAULT '-1',
`hash` varchar(32) DEFAULT NULL,
`topic` varchar(100) NOT NULL DEFAULT '',
`content` text NOT NULL,
Expand Down
1 change: 1 addition & 0 deletions SQL/Cleanup_patches/2020-09-09-RemoveHelpParentID.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE help DROP COLUMN parentID;
86 changes: 30 additions & 56 deletions modules/help_editor/ajax/process.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,60 +42,34 @@
),
]
);
} else {
//content does not exist insert the help file
if (!empty($_POST['section'])
&& $_POST['subsection'] != 'undefined'
&& empty($_POST['parentID'])
) {
//create parent help section first
$parentID = HelpFile::insert(
[
'hash' => md5($_POST['section']),
'topic' => "",
'content' => "Under construction",
'created' => date(
'Y-m-d h:i:s',
time()
),
]
);
// check errors
}
if (!empty($_POST['section'])
&& $_POST['subsection'] != 'undefined'
&& !empty($_POST['parentID'])
) {

// insert the help file
$helpID = HelpFile::insert(
[
'parentID' => $_POST['parentID'],
'hash' => md5($_POST['subsection']),
'topic' => $_POST['title'],
'content' => $_POST['content'],
'created' => date(
'Y-m-d h:i:s',
time()
),
]
);

} else if (!empty($_POST['section'])
&& $_POST['subsection'] == 'undefined'
) {
//default case
$helpID = HelpFile::insert(
[
'hash' => md5($_POST['section']),
'topic' => $_POST['title'],
'content' => $_POST['content'],
'created' => date(
'Y-m-d h:i:s',
time()
),
]
);
}
} else if (!empty($_POST['section'])
&& $_POST['subsection'] != 'undefined'
) {
// insert the help file
$helpID = HelpFile::insert(
[
'hash' => md5($_POST['subsection']),
'topic' => $_POST['title'],
'content' => $_POST['content'],
'created' => date(
'Y-m-d h:i:s',
time()
),
]
);
} else if (!empty($_POST['section'])
&& $_POST['subsection'] == 'undefined'
) {
//default case
$helpID = HelpFile::insert(
[
'hash' => md5($_POST['section']),
'topic' => $_POST['title'],
'content' => $_POST['content'],
'created' => date(
'Y-m-d h:i:s',
time()
),
]
);
}

2 changes: 1 addition & 1 deletion modules/help_editor/help/help_editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This module displays existing help content for LORIS modules and pages.

Use the *Selection Filter* section to search by Topic or Content keywords.

Click on the blue link in any *Topic* or *Parent Topic* column to edit the content within. Make your edits within the Edit Help Content page, and click **Save**.
Click on the blue link in any *Topic* column to edit the content within. Make your edits within the Edit Help Content page, and click **Save**.
2 changes: 0 additions & 2 deletions modules/help_editor/js/help_editor_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ $("#save-help").click(function(e) {
content = $('textarea[name="content"]').val(),
section = $("#section").val(),
subsection = $("#subsection").val(),
parentID = $("#parentID").val(),
helpID = $("#helpID").val(),
returnString = $("#return").val();

Expand All @@ -63,7 +62,6 @@ $("#save-help").click(function(e) {
content: content ? content : '',
section: section ? section : '',
subsection: subsection ? subsection : '',
parentID: parentID ? parentID : '',
helpID: helpID ? helpID : '',
},
success: function() {
Expand Down
11 changes: 2 additions & 9 deletions modules/help_editor/jsx/help_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,10 @@ class HelpEditor extends React.Component {
let result = <td>{cell}</td>;
switch (column) {
case 'Topic':
url = loris.BaseURL + '/help_editor/edit_help_content/?helpID=' +
row['Help ID'] + '&parentID=' + row['Parent ID'];
url = loris.BaseURL + '/help_editor/edit_help_content/?helpID='
+ row['Help ID'];
result = <td><a href ={url}>{cell}</a></td>;
break;
case 'Parent Topic':
url = loris.BaseURL + '/help_editor/edit_help_content/?helpID=' +
row['Parent ID'] + '&parentID=' + row['Parent Topic ID'];
result = <td><a href ={url}>{cell}</a></td>;
}

return result;
Expand Down Expand Up @@ -112,9 +108,6 @@ class HelpEditor extends React.Component {
name: 'topic',
type: 'text',
}},
{label: 'Parent ID', show: false},
{label: 'Parent Topic ID', show: false},
{label: 'Parent Topic', show: true},
{label: 'Content', show: true, filter: {
name: 'content',
type: 'text',
Expand Down
19 changes: 7 additions & 12 deletions modules/help_editor/php/edit_help_content.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,29 @@ class Edit_Help_Content extends \NDB_Form
$defaults = [];

// Sanitize user input
$safeSection = $_REQUEST['section'] ?
$safeSection = isset($_REQUEST['section']) ?
htmlspecialchars($_REQUEST['section']) : '';
$safeSubsection = $_REQUEST['subsection'] ?
$safeSubsection = isset($_REQUEST['subsection']) ?
htmlspecialchars($_REQUEST['subsection']) : '';

$defaults = [];

$helpID = '';
$parentID = '';
$helpID = '';
if (isset($_REQUEST['helpID'])) {
$helpID = htmlspecialchars($_REQUEST['helpID']);
}
if (isset($_GET['parentID'])) {
$parentID = htmlspecialchars($_GET['parentID']);
}
if (!empty($_REQUEST['section'])) {
if (isset($_REQUEST['section']) && !empty($_REQUEST['section'])) {
$helpID = HelpFile::hashToID(md5($_REQUEST['section']));
}
if (!empty($_REQUEST['section'])
if (isset($_REQUEST['section']) && !empty($_REQUEST['section'])
&& isset($_REQUEST['subsection'])
&& $_REQUEST['subsection'] != 'undefined'
) {
$helpID = HelpFile::hashToID(md5($_REQUEST['subsection']));
$parentID = HelpFile::hashToID(md5($_GET['section']));
$helpID = HelpFile::hashToID(md5($_REQUEST['subsection']));
}
$this->tpl_data['section'] = $safeSection;
$this->tpl_data['subsection'] = $safeSubsection;
$this->tpl_data['helpID'] = $helpID ? $helpID : '';
$this->tpl_data['parentID'] = $parentID ? $parentID : '';

if (!empty($helpID)) {
$help_file = HelpFile::factory($helpID);
Expand Down
Loading