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

Pagenumbers CleanupAction #273

Merged
merged 7 commits into from
Oct 29, 2015
Merged

Pagenumbers CleanupAction #273

merged 7 commits into from
Oct 29, 2015

Conversation

stefan-kolb
Copy link
Member

Replace pages field by num--num or keep existing field if Regex is not matching.
Pages field should only allow page range, i.e. num--num or page set 1,23,35.

Algorithm:

     * Format page numbers, separated either by commas or double-hyphens.
     * Converts the range number format of the <code>pages</code> field to page_number--page_number.
     * Removes all literals except [0-9,-].
     * Keeps the existing String if the resulting field does not match the expected Regex.
     *
     * <example>
     *     1-2 -> 1--2
     *     1,2,3 -> 1,2,3
     *     {1}-{2} -> 1--2
     *     Invalid -> Invalid
     * </example>

@stefan-kolb stefan-kolb changed the title Pagenumbers onSave action #131 Pagenumbers CleanupAction Oct 28, 2015
// replace
String newValue = matcher.replaceFirst(replace);
// replacement?
if(!newValue.equals(cleanValue)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

just return the new value

Copy link
Member Author

Choose a reason for hiding this comment

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

We want to return the initial value and not the cleaned value if page numbers regex does not match?!

Copy link
Contributor

Choose a reason for hiding this comment

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

ah ok. then leave this untouched.

// new value
String newValue = entry.getField("pages");
// undo action
ce.addEdit(new UndoableFieldChange(entry, "pages", oldValue, newValue));
Copy link
Contributor

Choose a reason for hiding this comment

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

we should only create the undo action if anything was actually changed (oldValue != newValue).

@stefan-kolb stefan-kolb removed this from the v2.80 milestone Oct 29, 2015
simonharrer added a commit that referenced this pull request Oct 29, 2015
@simonharrer simonharrer merged commit 7141196 into master Oct 29, 2015
@simonharrer simonharrer deleted the pagenumbers branch October 29, 2015 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants