From 9924b29461cf840b54d470f204f39c8e147f7857 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 4 Mar 2024 14:20:35 +0000 Subject: [PATCH] Bug 36221: Preparation This refactors the code for more DRY Signed-off-by: Lisette Scheer --- Koha/ILL/Backend/intra-includes/create.inc | 3 +- Koha/ILL/Backend/intra-includes/edititem.inc | 3 +- Koha/ILL/Backend/opac-includes/create.inc | 18 +++--- .../shared-includes/form_input_helpers.inc | 36 +++++++++++ .../Backend/shared-includes/forms/article.inc | 46 ++------------ .../Backend/shared-includes/forms/book.inc | 41 +------------ .../Backend/shared-includes/forms/chapter.inc | 56 ++--------------- .../shared-includes/forms/conference.inc | 55 ++++------------- .../Backend/shared-includes/forms/journal.inc | 26 +------- .../shared-includes/forms/resource.inc | 60 ++++--------------- .../Backend/shared-includes/forms/thesis.inc | 25 ++------ 11 files changed, 90 insertions(+), 279 deletions(-) create mode 100644 Koha/ILL/Backend/shared-includes/form_input_helpers.inc diff --git a/Koha/ILL/Backend/intra-includes/create.inc b/Koha/ILL/Backend/intra-includes/create.inc index 0130d22fa65..1df44f2974d 100644 --- a/Koha/ILL/Backend/intra-includes/create.inc +++ b/Koha/ILL/Backend/intra-includes/create.inc @@ -1,4 +1,6 @@ [% SET koha_version = Koha.Version %] +[% cwd = whole.cwd %] +[% PROCESS "${cwd}/shared-includes/form_input_helpers.inc" %] [% IF whole.error %] [% IF whole.status == 'missing_identifier' %]

Please Note: Mandatory field Identifier is missing.

@@ -73,7 +75,6 @@ - [% cwd = whole.cwd %] [% type = whole.value.other.type %] [% IF type %] [% INCLUDE "${cwd}/shared-includes/forms/${type}.inc" %] diff --git a/Koha/ILL/Backend/intra-includes/edititem.inc b/Koha/ILL/Backend/intra-includes/edititem.inc index d56d86e0135..2ba553dbf7a 100644 --- a/Koha/ILL/Backend/intra-includes/edititem.inc +++ b/Koha/ILL/Backend/intra-includes/edititem.inc @@ -1,3 +1,5 @@ +[% cwd = whole.cwd %] +[% PROCESS "${cwd}/shared-includes/form_input_helpers.inc" %] [% IF whole.error %] [% IF whole.status == 'missing_type' %]

Please Note: Mandatory field Type is missing.

@@ -66,7 +68,6 @@ - [% cwd = whole.cwd %] [% type = whole.value.other.type %] [% IF type %] [% INCLUDE "${cwd}/shared-includes/forms/${type}.inc" %] diff --git a/Koha/ILL/Backend/opac-includes/create.inc b/Koha/ILL/Backend/opac-includes/create.inc index 91450d66d21..b5adfd2d102 100644 --- a/Koha/ILL/Backend/opac-includes/create.inc +++ b/Koha/ILL/Backend/opac-includes/create.inc @@ -1,3 +1,6 @@ +[% PROCESS 'i18n.inc' %] +[% cwd = whole.cwd %] +[% PROCESS "${cwd}/shared-includes/form_input_helpers.inc" %] [% IF whole.error %] [% IF whole.status == 'missing_identifier' %]

Please Note: Mandatory field Identifier is missing.

@@ -21,9 +24,8 @@
General details
    + [% WRAPPER ill_select_field required = 1 id = 'type' label = t('Type') %]
  1. - - -
  2. + + [% END #ill_select_field %]
- [% cwd = whole.cwd %] [% type = whole.value.other.type %] [% IF type %] [% INCLUDE "${cwd}/shared-includes/forms/${type}.inc" %] @@ -84,8 +85,7 @@ Patron options
  1. - - + [% END #ill_select_field %]
@@ -122,4 +122,4 @@ [% INCLUDE "${cwd}/shared-includes/shared.js" %] // ]]> -[% END %] +[% END %] \ No newline at end of file diff --git a/Koha/ILL/Backend/shared-includes/form_input_helpers.inc b/Koha/ILL/Backend/shared-includes/form_input_helpers.inc new file mode 100644 index 00000000000..1ae8006bbd7 --- /dev/null +++ b/Koha/ILL/Backend/shared-includes/form_input_helpers.inc @@ -0,0 +1,36 @@ +[% BLOCK ill_text_input_field %] +
  • + + +
  • + [% SET required = 0 %] +[% END %] + +[% BLOCK ill_select_field %] + + + [% SET required = 0 %] +[% END %] + +[% BLOCK book_text_input_fields %] + [% PROCESS ill_text_input_field id = 'title' label = t('Title') value = whole.value.other.title %] + [% PROCESS ill_text_input_field id = 'author' label = t('Author') value = whole.value.other.author %] + [% PROCESS ill_text_input_field id = 'editor' label = t('Editor') value = whole.value.other.editor %] + [% PROCESS ill_text_input_field id = 'publisher' label = t('Publisher') value = whole.value.other.publisher %] + [% PROCESS ill_text_input_field id = 'published_place' label = t('Place of publication') value = whole.value.other.published_place %] + [% PROCESS ill_text_input_field id = 'year' label = t('Year') value = whole.value.other.year %] + [% PROCESS ill_text_input_field id = 'part_edition' label = t('Part / Edition') value = whole.value.other.part_edition %] + [% PROCESS ill_text_input_field id = 'volume' label = t('Volume') value = whole.value.other.volume %] + [% PROCESS ill_text_input_field id = 'isbn' label = t('ISBN') value = whole.value.other.isbn %] + [% PROCESS ill_text_input_field id = 'doi' label = t('DOI') value = whole.value.other.doi %] +[% END %] + +[% BLOCK journal_text_input_fields %] + [% PROCESS ill_text_input_field id = 'title' label = t('Title') value = whole.value.other.title %] + [% PROCESS ill_text_input_field id = 'volume' label = t('Volume') value = whole.value.other.volume %] + [% PROCESS ill_text_input_field id = 'issue' label = t('Issue number') value = whole.value.other.issue %] + [% PROCESS ill_text_input_field id = 'year' label = t('Year') value = whole.value.other.issue %] + [% PROCESS ill_text_input_field id = 'issn' label = t('ISSN') value = whole.value.other.issn %] +[% END %] \ No newline at end of file diff --git a/Koha/ILL/Backend/shared-includes/forms/article.inc b/Koha/ILL/Backend/shared-includes/forms/article.inc index ad4b4c693e8..07a52d3eaed 100644 --- a/Koha/ILL/Backend/shared-includes/forms/article.inc +++ b/Koha/ILL/Backend/shared-includes/forms/article.inc @@ -1,50 +1,16 @@
    Journal details
      -
    1. - - -
    2. -
    3. - - -
    4. -
    5. - - -
    6. -
    7. - - -
    8. -
    9. - - -
    10. + [% PROCESS journal_text_input_fields %]
    Article details
      -
    1. - - -
    2. -
    3. - - -
    4. -
    5. - - -
    6. -
    7. - - -
    8. -
    9. - - -
    10. + [% PROCESS ill_text_input_field id = 'article_title' label = t('Article title') value = whole.value.other.article_title %] + [% PROCESS ill_text_input_field id = 'article_author' label = t('Article author') value = whole.value.other.article_author %] + [% PROCESS ill_text_input_field id = 'published_date' label = t('Publication date') value = whole.value.other.published_date %] + [% PROCESS ill_text_input_field id = 'pages' label = t('Pages') value = whole.value.other.pages %] + [% PROCESS ill_text_input_field id = 'doi' label = t('DOI') value = whole.value.other.doi %]
    diff --git a/Koha/ILL/Backend/shared-includes/forms/book.inc b/Koha/ILL/Backend/shared-includes/forms/book.inc index 397477d18f9..0f84f669011 100644 --- a/Koha/ILL/Backend/shared-includes/forms/book.inc +++ b/Koha/ILL/Backend/shared-includes/forms/book.inc @@ -1,45 +1,6 @@
    Book details
      -
    1. - - -
    2. -
    3. - - -
    4. -
    5. - - -
    6. -
    7. - - -
    8. -
    9. - - -
    10. -
    11. - - -
    12. -
    13. - - -
    14. -
    15. - - -
    16. -
    17. - - -
    18. -
    19. - - -
    20. + [% PROCESS book_text_input_fields %]
    diff --git a/Koha/ILL/Backend/shared-includes/forms/chapter.inc b/Koha/ILL/Backend/shared-includes/forms/chapter.inc index aafec86f15e..48312571931 100644 --- a/Koha/ILL/Backend/shared-includes/forms/chapter.inc +++ b/Koha/ILL/Backend/shared-includes/forms/chapter.inc @@ -1,62 +1,14 @@
    Book details
      -
    1. - - -
    2. -
    3. - - -
    4. -
    5. - - -
    6. -
    7. - - -
    8. -
    9. - - -
    10. -
    11. - - -
    12. -
    13. - - -
    14. -
    15. - - -
    16. -
    17. - - -
    18. -
    19. - - -
    20. + [% PROCESS book_text_input_fields %]
    Chapter details
      -
    1. - - -
    2. -
    3. - - -
    4. -
    5. - - -
    6. + [% PROCESS ill_text_input_field id = 'chapter_author' label = t('Author') value = whole.value.other.chapter_author %] + [% PROCESS ill_text_input_field id = 'chapter' label = t('Chapter') value = whole.value.other.chapter %] + [% PROCESS ill_text_input_field id = 'pages' label = t('Pages') value = whole.value.other.pages %]
    diff --git a/Koha/ILL/Backend/shared-includes/forms/conference.inc b/Koha/ILL/Backend/shared-includes/forms/conference.inc index ca95d5ce6ca..ce74a27e59a 100644 --- a/Koha/ILL/Backend/shared-includes/forms/conference.inc +++ b/Koha/ILL/Backend/shared-includes/forms/conference.inc @@ -1,49 +1,16 @@
    Conference details
      -
    1. - - -
    2. -
    3. - - -
    4. -
    5. - - -
    6. -
    7. - - -
    8. -
    9. - - -
    10. -
    11. - - -
    12. -
    13. - - -
    14. -
    15. - - -
    16. -
    17. - - -
    18. -
    19. - - -
    20. -
    21. - - -
    22. + [% PROCESS ill_text_input_field id = 'title' label = t('Conference title') value = whole.value.other.title %] + [% PROCESS ill_text_input_field id = 'publication' label = t('Publication') value = whole.value.other.publication %] + [% PROCESS ill_text_input_field id = 'conference_date' label = t('Conference date') value = whole.value.other.conference_date %] + [% PROCESS ill_text_input_field id = 'venue' label = t('Venue') value = whole.value.other.venue %] + [% PROCESS ill_text_input_field id = 'sponsor' label = t('Sponsor') value = whole.value.other.sponsor %] + [% PROCESS ill_text_input_field id = 'volume' label = t('Volume') value = whole.value.other.volume %] + [% PROCESS ill_text_input_field id = 'isbn' label = t('ISBN') value = whole.value.other.isbn %] + [% PROCESS ill_text_input_field id = 'issn' label = t('ISSN') value = whole.value.other.issn %] + [% PROCESS ill_text_input_field id = 'part_edition' label = t('Part') value = whole.value.other.part_edition %] + [% PROCESS ill_text_input_field id = 'paper_title' label = t('Paper title') value = whole.value.other.paper_title %] + [% PROCESS ill_text_input_field id = 'paper_author' label = t('Paper author') value = whole.value.other.paper_author %]
    diff --git a/Koha/ILL/Backend/shared-includes/forms/journal.inc b/Koha/ILL/Backend/shared-includes/forms/journal.inc index 5b94b93a3f9..80b05ddfd81 100644 --- a/Koha/ILL/Backend/shared-includes/forms/journal.inc +++ b/Koha/ILL/Backend/shared-includes/forms/journal.inc @@ -1,29 +1,7 @@
    Journal details
      -
    1. - - -
    2. -
    3. - - -
    4. -
    5. - - -
    6. -
    7. - - -
    8. -
    9. - - -
    10. -
    11. - - -
    12. + [% PROCESS journal_text_input_fields %] + [% PROCESS ill_text_input_field id = 'doi' label = t('DOI') value = whole.value.other.doi %]
    diff --git a/Koha/ILL/Backend/shared-includes/forms/resource.inc b/Koha/ILL/Backend/shared-includes/forms/resource.inc index a475634fe67..b24a76463cb 100644 --- a/Koha/ILL/Backend/shared-includes/forms/resource.inc +++ b/Koha/ILL/Backend/shared-includes/forms/resource.inc @@ -1,53 +1,17 @@
    Generic resource details
      -
    1. - - -
    2. -
    3. - - -
    4. -
    5. - - -
    6. -
    7. - - -
    8. -
    9. - - -
    10. -
    11. - - -
    12. -
    13. - - -
    14. -
    15. - - -
    16. -
    17. - - -
    18. -
    19. - - -
    20. -
    21. - - -
    22. -
    23. - - -
    24. + [% PROCESS ill_text_input_field id = 'title' label = t('Title') value = whole.value.other.title %] + [% PROCESS ill_text_input_field id = 'author' label = t('Author') value = whole.value.other.author %] + [% PROCESS ill_text_input_field id = 'editor' label = t('Editor') value = whole.value.other.editor %] + [% PROCESS ill_text_input_field id = 'publisher' label = t('Publisher') value = whole.value.other.publisher %] + [% PROCESS ill_text_input_field id = 'published_place' label = t('Place of publication') value = whole.value.other.published_place %] + [% PROCESS ill_text_input_field id = 'year' label = t('Year') value = whole.value.other.year %] + [% PROCESS ill_text_input_field id = 'part_edition' label = t('Part / Edition') value = whole.value.other.part_edition %] + [% PROCESS ill_text_input_field id = 'volume' label = t('Volume') value = whole.value.other.volume %] + [% PROCESS ill_text_input_field id = 'pages' label = t('Pages') value = whole.value.other.pages %] + [% PROCESS ill_text_input_field id = 'isbn' label = t('ISBN') value = whole.value.other.isbn %] + [% PROCESS ill_text_input_field id = 'issn' label = t('ISSN') value = whole.value.other.issn %] + [% PROCESS ill_text_input_field id = 'doi' label = t('DOI') value = whole.value.other.doi %]
    diff --git a/Koha/ILL/Backend/shared-includes/forms/thesis.inc b/Koha/ILL/Backend/shared-includes/forms/thesis.inc index a170d665561..af99af03de8 100644 --- a/Koha/ILL/Backend/shared-includes/forms/thesis.inc +++ b/Koha/ILL/Backend/shared-includes/forms/thesis.inc @@ -1,25 +1,10 @@
    Thesis details
      -
    1. - - -
    2. -
    3. - - -
    4. -
    5. - - -
    6. -
    7. - - -
    8. -
    9. - - -
    10. + [% PROCESS ill_text_input_field id = 'title' label = t('Title') value = whole.value.other.title %] + [% PROCESS ill_text_input_field id = 'author' label = t('Author') value = whole.value.other.author %] + [% PROCESS ill_text_input_field id = 'institution' label = t('Institution') value = whole.value.other.institution %] + [% PROCESS ill_text_input_field id = 'published_date' label = t('Publication date') value = whole.value.other.published_date %] + [% PROCESS ill_text_input_field id = 'doi' label = t('DOI') value = whole.value.other.doi %]
    -- 2.39.2