Page MenuHomePhabricator

Save-And-Continue not fully supported by Multi-Instance-Templates
Open, Needs TriagePublic

Description

In a form with a multi-instance-template and the save-and-continue button this button is not switched on in all situations where it should be:

  • adding a new instance
  • removing an existing instance
  • changing the order via drag-and-drop

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 2 2018, 5:50 PM

I have a patch to fix this. But where should I put it and how?

@Emwiemaikel: Thanks for taking a look at the code! You are very welcome to use developer access to submit the proposed code changes as a Git branch directly into Gerrit (repository: mediawiki/extensions/PageForms). If you don't want to set up Git/Gerrit, you can also use the Gerrit Patch Uploader. Thanks again!

@Emwiemaikel: Did you manage to upload your patch? Do you need any help? :)

@Aklapper I really have problems with the gerrit setup here. I followed the Gerrit-Tutorial which is partially good.

  • But I had to learn where I need to put my SSH key the hard way :(
  • I did it on phabricator and mediawiki but not on Gerrit, itself :(
  • Further, the browsing support for the repos is really bad, compared to github and bitbucket :(
  • I cannot use git-review thus apparently there is no way for me to push anything to anywhere ;(
  • I cannot create a branch as recommended in the gerrit-tutorial :(
  • I cannot use the patch-uploader "No existing author found with 'erdmann@diqa-pm.com'" ;(

Overall this work experience is really bad. Will copy and paste the patch to my next comment :|

diff --git a/libs/PF_submit.js b/libs/PF_submit.js
index 0120f361..94b33ca4 100644
--- a/libs/PF_submit.js
+++ b/libs/PF_submit.js
@@ -87,7 +87,7 @@
 
 			var oldsummary = summaryfield.attr( 'value' );
 
-			if ( oldsummary !== '' ) {
+			if ( oldsummary !== undefined && oldsummary !== '' ) {
 				summaryfield.attr( 'value', oldsummary + ' (' + saveAndContinueSummary + ')' );
 			} else {
 				summaryfield.attr( 'value', saveAndContinueSummary );
diff --git a/libs/PageForms.js b/libs/PageForms.js
index 7b6e9951..b0086097 100644
--- a/libs/PageForms.js
+++ b/libs/PageForms.js
@@ -1167,6 +1167,10 @@ $.fn.addInstance = function( addAboveCurInstance ) {
 	// Global variable.
 	num_elements++;
 
+	// Enable save and continue since the form changes
+	$("#wpSaveAndContinue").addClass('pf-save_and_continue-changed');
+	$("#wpSaveAndContinue").removeAttr("disabled");
+
 	// Create the new instance
 	var new_div = wrapper
 		.find(".multipleTemplateStarter")
@@ -1490,6 +1494,11 @@ $.fn.initializeJSElements = function( partOfMultiple ) {
 					$(this).remove();
 				});
 			});
+
+			// Enable save and continue since the form has changed
+			$("#wpSaveAndContinue").addClass('pf-save_and_continue-changed');
+			$("#wpSaveAndContinue").removeAttr("disabled");
+
 			return false;
 		});
 
@@ -1681,6 +1690,12 @@ $(document).ready( function() {
 		}
 	});
 
+	// Enable save and continue since the form has changed
+	$( ".multipleTemplateList" ).on( "sortupdate", function( event, ui ) {
+		$("#wpSaveAndContinue").addClass('pf-save_and_continue-changed');
+		$("#wpSaveAndContinue").removeAttr("disabled");
+	} );
+
 	// If the form is submitted, validate everything!
 	$('#pfForm').submit( function() {
 		return validateAll();

@Aklapper I really have problems with the gerrit setup here.

@Emwiemaikel: Thanks for the feedback! Would you be willing to bring up and discuss these issues at https://www.mediawiki.org/wiki/Talk:Gerrit/Tutorial (and provide more info what exactly went wrong) so we can try to improve the documentation?