mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-02 09:58:24 +01:00
When users submit a no-op edit in Phriction, don't update the document
Summary: See T1501. When users mash "save", stop them if they didn't change anything. Also, don't default-fill the "edit notes" field with the previous notes. This is meant to be more like a commit message for your changes. Test Plan: Edited a document with no changes, got a dialog. Edited a document with a title change only and a description change only, things worked. Edited a document with a previous "Edit notes", got a blank default fill. Reviewers: alanh, btrahan, vrana Reviewed By: vrana CC: aran Maniphest Tasks: T1501 Differential Revision: https://secure.phabricator.com/D2978
This commit is contained in:
parent
23f2ffb81c
commit
8fd97f4352
1 changed files with 20 additions and 2 deletions
|
@ -103,10 +103,12 @@ final class PhrictionEditController
|
||||||
require_celerity_resource('phriction-document-css');
|
require_celerity_resource('phriction-document-css');
|
||||||
|
|
||||||
$e_title = true;
|
$e_title = true;
|
||||||
|
$notes = null;
|
||||||
$errors = array();
|
$errors = array();
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
$title = $request->getStr('title');
|
$title = $request->getStr('title');
|
||||||
|
$notes = $request->getStr('description');
|
||||||
|
|
||||||
if (!strlen($title)) {
|
if (!strlen($title)) {
|
||||||
$e_title = 'Required';
|
$e_title = 'Required';
|
||||||
|
@ -115,12 +117,27 @@ final class PhrictionEditController
|
||||||
$e_title = null;
|
$e_title = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($document->getID()) {
|
||||||
|
if ($content->getTitle() == $title &&
|
||||||
|
$content->getContent() == $request->getStr('content')) {
|
||||||
|
|
||||||
|
$dialog = new AphrontDialogView();
|
||||||
|
$dialog->setUser($user);
|
||||||
|
$dialog->setTitle('No Edits');
|
||||||
|
$dialog->appendChild(
|
||||||
|
'<p>You did not make any changes to the document.</p>');
|
||||||
|
$dialog->addCancelButton($request->getRequestURI());
|
||||||
|
|
||||||
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!count($errors)) {
|
if (!count($errors)) {
|
||||||
$editor = id(PhrictionDocumentEditor::newForSlug($document->getSlug()))
|
$editor = id(PhrictionDocumentEditor::newForSlug($document->getSlug()))
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
->setTitle($title)
|
->setTitle($title)
|
||||||
->setContent($request->getStr('content'))
|
->setContent($request->getStr('content'))
|
||||||
->setDescription($request->getStr('description'));
|
->setDescription($notes);
|
||||||
|
|
||||||
$editor->save();
|
$editor->save();
|
||||||
|
|
||||||
|
@ -195,6 +212,7 @@ final class PhrictionEditController
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
->setWorkflow(true)
|
||||||
->setAction($request->getRequestURI()->getPath())
|
->setAction($request->getRequestURI()->getPath())
|
||||||
->addHiddenInput('slug', $document->getSlug())
|
->addHiddenInput('slug', $document->getSlug())
|
||||||
->addHiddenInput('nodraft', $request->getBool('nodraft'))
|
->addHiddenInput('nodraft', $request->getBool('nodraft'))
|
||||||
|
@ -220,7 +238,7 @@ final class PhrictionEditController
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTextControl())
|
id(new AphrontFormTextControl())
|
||||||
->setLabel('Edit Notes')
|
->setLabel('Edit Notes')
|
||||||
->setValue($content->getDescription())
|
->setValue($notes)
|
||||||
->setError(null)
|
->setError(null)
|
||||||
->setName('description'))
|
->setName('description'))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
|
|
Loading…
Add table
Reference in a new issue