From e5042cc5c1839e5a5a8168336ad1e2705133ffba Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 16 Mar 2022 16:49:00 +0100 Subject: [PATCH] Bug 32030: ERM - Vue version First, `yarn install`. Then use `yarn build_js` or `yarn watch_js` to regenerate the dist/main.js file Signed-off-by: Jonathan Field Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- Koha/ERM/Agreement.pm | 31 +- erm/agreements.pl | 139 +---- .../prog/en/includes/calendar.inc | 7 +- .../prog/en/includes/js-date-format.inc | 6 + .../prog/en/includes/patron-search.inc | 14 +- .../prog/en/modules/erm/agreements.tt | 526 +----------------- .../intranet-tmpl/prog/js/vue/Agreements.vue | 116 ++++ .../vue/components/ERM/AgreementPeriods.vue | 98 ++++ .../vue/components/ERM/AgreementUserRoles.vue | 112 ++++ .../components/ERM/AgreementsButtonDelete.vue | 9 + .../components/ERM/AgreementsButtonEdit.vue | 9 + .../vue/components/ERM/AgreementsFormAdd.vue | 283 ++++++++++ .../ERM/AgreementsFormConfirmDelete.vue | 96 ++++ .../js/vue/components/ERM/AgreementsList.vue | 192 +++++++ .../vue/components/ERM/AgreementsToolbar.vue | 15 + .../intranet-tmpl/prog/js/vue/main-erm.ts | 18 + package.json | 35 +- tsconfig.json | 4 + webpack.config.js | 36 ++ 19 files changed, 1081 insertions(+), 665 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/Agreements.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementPeriods.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementUserRoles.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsButtonDelete.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsButtonEdit.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsToolbar.vue create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/main-erm.ts create mode 100644 tsconfig.json create mode 100644 webpack.config.js diff --git a/Koha/ERM/Agreement.pm b/Koha/ERM/Agreement.pm index 2b8789b36c..5ca06e3be8 100644 --- a/Koha/ERM/Agreement.pm +++ b/Koha/ERM/Agreement.pm @@ -41,7 +41,20 @@ Returns the periods for this agreement =cut sub periods { - my ( $self ) = @_; + my ( $self, $periods ) = @_; + + if ( $periods ) { + my $schema = $self->_result->result_source->schema; + $schema->txn_do( + sub { + $self->periods->delete; + + for my $period (@$periods) { + $self->_result->add_to_erm_agreement_periods($period); + } + } + ); + } my $periods_rs = $self->_result->erm_agreement_periods; return Koha::ERM::Agreement::Periods->_new_from_dbic($periods_rs); @@ -54,8 +67,20 @@ Returns the user roles for this agreement =cut sub user_roles { - my ( $self ) = @_; - + my ( $self, $user_roles ) = @_; + + if ( $user_roles ) { + my $schema = $self->_result->result_source->schema; + $schema->txn_do( + sub { + $self->user_roles->delete; + + for my $user_role (@$user_roles) { + $self->_result->add_to_erm_agreement_user_roles($user_role); + } + } + ); + } my $user_roles_rs = $self->_result->erm_agreement_user_roles; return Koha::ERM::Agreement::UserRoles->_new_from_dbic($user_roles_rs); } diff --git a/erm/agreements.pl b/erm/agreements.pl index 88dfa1a550..99485df904 100755 --- a/erm/agreements.pl +++ b/erm/agreements.pl @@ -26,9 +26,6 @@ use Koha::Acquisition::Booksellers; use Koha::ERM::Agreements; my $input = CGI->new; -my $agreement_id = $input->param('agreement_id'); -my $op = $input->param('op') || 'list'; -my @messages; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -39,142 +36,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -my $dbh = C4::Context->dbh; -if ( $op eq 'add_form' ) { - my $agreement; - if ($agreement_id) { - $agreement = Koha::ERM::Agreements->find($agreement_id); - } - - $template->param( agreement => $agreement, ); -} -elsif ( $op eq 'add_validate' ) { - my $vendor_id = $input->param('vendor_id'); - my $name = $input->param('name'); - my $description = $input->param('description'); - my $status = $input->param('status'); - my $closure_reason = $input->param('closure_reason'); - my $is_perpetual = $input->param('is_perpetual'); - my $renewal_priority = $input->param('renewal_priority'); - my $license_info = $input->param('license_info'); - - my $schema = Koha::Database->new->schema; - $schema->txn_do(sub{ - my ( $stored, $agreement ); - if ($agreement_id) { - $agreement = Koha::ERM::Agreements->find($agreement_id); - $agreement->vendor_id($vendor_id); - $agreement->name($name); - $agreement->description($description); - $agreement->status($status); - $agreement->closure_reason($closure_reason); - $agreement->is_perpetual($is_perpetual); - $agreement->renewal_priority($renewal_priority); - $agreement->license_info($license_info); - - eval { $agreement->store; }; - if ($@) { - push @messages, { type => 'error', code => 'error_on_update' }; - } - else { - $stored = 1; - push @messages, { type => 'message', code => 'success_on_update' }; - } - } - else { - $agreement = Koha::ERM::Agreement->new( - { - vendor_id => $vendor_id, - name => $name, - description => $description, - status => $status, - closure_reason => $closure_reason, - is_perpetual => $is_perpetual, - renewal_priority => $renewal_priority, - license_info => $license_info, - } - ); - eval { $agreement->store; }; - if ($@) { - push @messages, { type => 'error', code => 'error_on_insert' }; - } - else { - $stored = 1; - push @messages, { type => 'message', code => 'success_on_insert' }; - } - } - - if ( $stored ) { - if ( $agreement_id ) { - $agreement->periods->delete; - $agreement->user_roles->delete; - } - for my $unique_id ( $input->multi_param('period_unique_id') ) { - my $started_on = $input->param( 'started_on_' . $unique_id ); - next unless $started_on; - my $ended_on = $input->param( 'ended_on_' . $unique_id ); - my $cancellation_deadline = $input->param( 'cancellation_deadline_' . $unique_id ); - my $notes = $input->param( 'notes_' . $unique_id ); - - $started_on = dt_from_string($started_on); - $ended_on &&= dt_from_string($ended_on); - $cancellation_deadline &&= dt_from_string($cancellation_deadline); - - Koha::ERM::Agreement::Period->new( - { - agreement_id => $agreement->agreement_id, - started_on => $started_on, - ended_on => $ended_on, - cancellation_deadline => $cancellation_deadline, - notes => $notes, - } - )->store; - } - - for my $unique_id ( $input->multi_param('user_unique_id') ) { - my $user_id = $input->param('user_id_' . $unique_id); - next unless $user_id; - my $role = $input->param('user_role_' . $unique_id); - Koha::ERM::Agreement::UserRole->new( - { - agreement_id => $agreement->agreement_id, - user_id => $user_id, - role => $role, - } - )->store; - } - - } - }); - $op = 'list'; -} -elsif ( $op eq 'delete_confirm' ) { - my $agreement = Koha::ERM::Agreements->find($agreement_id); - $template->param( agreement => $agreement, ); -} -elsif ( $op eq 'delete_confirmed' ) { - my $agreement = Koha::ERM::Agreements->find($agreement_id); - my $deleted = eval { $agreement->delete; }; - - if ( $@ or not $deleted ) { - push @messages, { type => 'error', code => 'error_on_delete' }; - } - else { - push @messages, { type => 'message', code => 'success_on_delete' }; - } - $op = 'list'; -} - -if ( $op eq 'list' ) { - $template->param( - agreements_count => Koha::ERM::Agreements->search->count ); -} - $template->param( - vendors => Koha::Acquisition::Booksellers->search, - agreement_id => $agreement_id, - messages => \@messages, - op => $op, + vendors => Koha::Acquisition::Booksellers->search, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 9cdc8b8e0c..eefc245d69 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -33,7 +33,7 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc index cb97afa9c3..901fda04c8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -843,11 +843,15 @@ } function select_user(borrowernumber, data) { var p = window.opener; - [% IF callback %] - p.[% callback | html %](borrowernumber, data); - [% ELSE %] - p.select_user(borrowernumber, data); - [% END %] + if ( p.document.getElementById("selected_patron_id") ) { + p.document.getElementById("selected_patron_id").value = borrowernumber; + } else { + [% IF callback %] + p.[% callback | html %](borrowernumber, data); + [% ELSE %] + p.select_user(borrowernumber, data); + [% END %] + } window.close(); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/agreements.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/agreements.tt index 092b61e3f4..76c217a4b7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/erm/agreements.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/erm/agreements.tt @@ -34,37 +34,9 @@ Electronic resources management - [% IF op == 'add_form' %] -
  • - Agreements -
  • -
  • - - [% IF agreement.agreement_id %] - Modify - [% ELSE %] - New - [% END %] Agreement - -
  • - - [% ELSIF op == 'delete_confirm' %] -
  • - Agreements -
  • -
  • - - Confirm deletion of agreement - -
  • - - [% ELSE %] -
  • - - Agreements - -
  • - [% END %] +
  • + Agreements +
  • @@ -73,284 +45,7 @@
    -[% FOR m IN messages %] -
    - [% SWITCH m.code %] - [% CASE 'error_on_update' %] - An error occurred when updating this agreement. Perhaps it already exists. - [% CASE 'error_on_insert' %] - An error occurred when adding this agreement. The agreement id might already exist. - [% CASE 'error_on_delete' %] - An error occurred when deleting this agreement. Check the logs. - [% CASE 'success_on_update' %] - Agreement updated successfully. - [% CASE 'success_on_insert' %] - Agreement added successfully. - [% CASE 'success_on_delete' %] - Agreement deleted successfully. - [% CASE 'already_exists' %] - This agreement already exists. - [% CASE %] - [% m.code | html %] - [% END %] -
    -[% END %] - -[% IF op == 'add_form' %] - [% IF agreement %] -

    Modify a agreement

    - [% ELSE %] -

    New agreement

    - [% END %] - -
    - - - -
    -
      - [% IF agreement %] -
    1. Agreement ID: [% agreement.agreement_id | html %]
    2. - [% END %] - -
    3. - - -
    4. -
    5. - - Required -
    6. - - -
    7. - - - Required -
    8. -
    9. - - -
    10. -
    11. - - - -
    12. -
    13. - - -
    14. - - -
    15. -
    -
    - -[% BLOCK agreement_period %] -
    - - Agreement period [% id | html %] - Remove this period - - -
      -
    1. - - - Required -
      [% INCLUDE 'date-format.inc' %]
      -
    2. -
    3. - - -
      [% INCLUDE 'date-format.inc' %]
      -
    4. -
    5. - - -
      [% INCLUDE 'date-format.inc' %]
      -
    6. -
    7. - - -
    8. -
    -
    -[% END %] - -
    - Periods - [% IF agreement.periods.count %] - [% FOR p IN agreement.periods %] - [% PROCESS agreement_period period => p, id => loop.count %] - [% END %] - [% ELSE %] - [% PROCESS agreement_period id => 1 %] - [% END %] - -
    - -[% BLOCK agreement_user %] -
    - - User [% id | html %] - Remove this user - - - -
      -
    1. - - - [% IF u %] - - [% INCLUDE 'patron-title.inc' patron = u.patron %] - - - [% END %] - - (Select user) -
    2. - -
    3. - - -
    4. -
    -
    -[% END %] - -
    - Users - [% IF agreement.user_roles.count %] - [% FOR u IN agreement.user_roles %] - [% PROCESS agreement_user user => u, id => loop.count %] - [% END %] - [% ELSE %] - [% PROCESS agreement_user, id => 1 %] - [% END %] - - -
    - -
    - - Cancel -
    -
    -[% END %] - -[% IF op == 'delete_confirm' %] -
    -

    Delete agreement "[% agreement.agreement_id | html %]?"

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Agreement id[% agreement.agreement_id| html %]
    Vendor[% agreement.vendor_id| html %]
    Name[% agreement.name| html %]
    Description[% agreement.description| html %]
    Status[% agreement.status| html %]
    Closure_reason[% agreement.closure_reason| html %]
    Is perpetual[% agreement.is_perpetual| html %]
    Renewal priority[% agreement.renewal_priority| html %]
    License info[% agreement.license_info| html %]
    -
    - - - -
    -
    - -
    -
    -[% END %] - -[% IF op == 'list' %] - - - -

    Agreements

    - [% IF agreement_name_filter %] - Searching: [% agreement_name_filter | html %] - [% END %] - - [% IF agreements_count > 0 %] -
    - - - - - - - - - - - - - - -
    IDVendorNameDescriptionStatusClosure reasonIs perpetualRenewal priorityActions
    - [% ELSE %] -
    - There are no agreements defined. Create a new agreement. -
    - [% END %] -[% END %] +
    @@ -368,29 +63,18 @@ [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] [% INCLUDE 'js-patron-format.inc' %] + [% INCLUDE 'js-date-format.inc' %] + - var agreements_table = $("#table_agreements").kohaTable({ - "ajax": { - "url": agreements_table_url - }, - "order": [[ 1, "asc" ]], - "columns": [ - { - "data": "agreement_id", - "searchable": true, - "orderable": true - }, - { - "data": "vendor_id", - "searchable": true, - "orderable": true - }, - { - "data": "name", - "searchable": true, - "orderable": true - }, - { - "data": "description", - "searchable": true, - "orderable": true - }, - { - "data": "status", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { - return escape_str(agreement_statuses_map[row.status].lib); - } - }, - { - "data": "closure_reason", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { - return row.closure_reason != undefined && row.closure_reason != "" ? escape_str(agreement_closure_reasons_map[row.closure_reason].lib) : ""; - } - }, - { - "data": "is_perpetual", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { - return escape_str(row.is_perpetual ? _("Yes") : _("No")); - } - }, - { - "data": "renewal_priority", - "searchable": true, - "orderable": true, - "render": function( data, type, row, meta ) { - return row.renewal_priority != undefined && row.renewal_priority != "" ? escape_str(agreement_renewal_priorities_map[row.renewal_priority].lib) : ""; - } - }, - { - "data": function( row, type, val, meta ) { - - var result = ' '+_("Edit")+''+"\n"; - result += ' '+_("Delete")+''; - return result; - - }, - "searchable": false, - "orderable": false - } - ] - }, columns_settings, 1); - - $(".add_new_period").on("click", function(e){ - e.preventDefault(); - let first_period_block = $("fieldset.agreement_period:first"); - if ( first_period_block.is(":visible") ) { - let new_period_block = first_period_block.clone(1); - new_period_block.find("input").val(""); - $(new_period_block).insertBefore(this); - } else { - first_period_block.show(); - } - update_period_count(); - }); - $(".remove_period").on("click", function(e){ - e.preventDefault(); - let fieldset = $(this).parent().parent(); - if ( $("fieldset.agreement_period").length == 1 ) { - clear_block(fieldset); - fieldset.hide(); - } else { - fieldset.remove(); - } - update_period_count(); - }); - - $(".add_new_user_block").on("click",function(e){ - e.preventDefault(); - let first_user_block = $("fieldset.agreement_user:first"); - if ( first_user_block.is(":visible") ) { - let new_user_block = $("fieldset.agreement_user:first").clone(1); - new_user_block.find("span.user").empty(); - clear_block(new_user_block); - $(new_user_block).insertBefore(this); - } else { - first_user_block.show(); - } - - update_user_count(); - }); - $(".remove_user").on("click", function(e){ - e.preventDefault(); - let fieldset = $(this).parent().parent(); - if ( $("fieldset.agreement_user").length == 1 ) { - fieldset.find("span.user").empty(); - clear_block(fieldset); - fieldset.hide(); - } else { - fieldset.remove(); - } - - update_user_count(); - }); - - $(".pick_user").on("click", function(e){ - e.preventDefault(); - current_user_node = $(this).closest("fieldset"); - window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=select&filter=erm_users", - 'PatronPopup', - 'width=740,height=450,location=yes,toolbar=no,' - + 'scrollbars=yes,resize=yes' - ); - }); - - update_period_count(); - update_user_count(); - }); - - function clear_block(block){ - $(block).find('input').val(""); - $(block).find("select option:first-child").attr("selected", "selected"); - } - function update_period_count(){ - $("fieldset.agreement_period").each(function(i, period){ - let id = i + 1; - $(period).find(".period_count").text(id); - $(period).find("input[name='period_unique_id']").val(id); - - let ended_on_input = $(period).find("input.ended_on"); - $(ended_on_input).attr("id", "ended_on_" + id); - $(ended_on_input).attr("name", "ended_on_" + id); - $(ended_on_input).flatpickr(); - - let started_on_input = $(period).find("input.started_on"); - $(started_on_input).attr("name", "started_on_" + id); - $(started_on_input).data("date_to", "ended_on_" + id); - $(started_on_input).flatpickr(); - - let cancellation_deadline_input = $(period).find("input.cancellation_deadline"); - $(cancellation_deadline_input).attr("name", "cancellation_deadline_" + id); - $(cancellation_deadline_input).flatpickr(); - - $(period).find(".notes").attr("name", "notes_" + id); - $(period).attr('id', 'agreement_period_' + id); - }); - } - - function update_user_count(){ - $("fieldset.agreement_user").each(function(i, user){ - let id = i + 1; - let remove_user_link = $(this).find(".remove_user"); - $(user).find(".user_count").text(id); - $(user).find("input[name='user_unique_id']").val(id); - - $(user).find(".user_id").attr("name", "user_id_" + id); - $(user).find(".user_role").attr("name", "user_role_" + id); - }); - } - - function select_user(borrowernumber, patron) { - patron['patron_id'] = borrowernumber; - let unique_id = $(current_user_node).find("input[name='user_unique_id']").val(); - let a = '' + $patron_to_html(patron) + ' ' - + ''; - $(current_user_node).find("span.user").html(a); - } - + [% Asset.js("js/vue/dist/main.js") %] + [% Asset.js("js/vue/dist/runtime.js") %] - [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/Agreements.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/Agreements.vue new file mode 100644 index 0000000000..813b769bd3 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/Agreements.vue @@ -0,0 +1,116 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementPeriods.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementPeriods.vue new file mode 100644 index 0000000000..1d914dc6be --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementPeriods.vue @@ -0,0 +1,98 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementUserRoles.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementUserRoles.vue new file mode 100644 index 0000000000..6571f5201e --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementUserRoles.vue @@ -0,0 +1,112 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsButtonDelete.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsButtonDelete.vue new file mode 100644 index 0000000000..6f82ae9aed --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsButtonDelete.vue @@ -0,0 +1,9 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsButtonEdit.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsButtonEdit.vue new file mode 100644 index 0000000000..ea7f6a671f --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsButtonEdit.vue @@ -0,0 +1,9 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue new file mode 100644 index 0000000000..0f81913d40 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormAdd.vue @@ -0,0 +1,283 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue new file mode 100644 index 0000000000..36737cd705 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsFormConfirmDelete.vue @@ -0,0 +1,96 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue new file mode 100644 index 0000000000..329ac462f8 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsList.vue @@ -0,0 +1,192 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsToolbar.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsToolbar.vue new file mode 100644 index 0000000000..61198d9733 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/AgreementsToolbar.vue @@ -0,0 +1,15 @@ + + + diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/main-erm.ts b/koha-tmpl/intranet-tmpl/prog/js/vue/main-erm.ts new file mode 100644 index 0000000000..ecb0e1cefc --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/main-erm.ts @@ -0,0 +1,18 @@ +import {createApp} from 'vue' +import BootstrapVue3 from 'bootstrap-vue-3' + +//import 'bootstrap/dist/css/bootstrap.css' +import 'bootstrap-vue-3/dist/bootstrap-vue-3.css' + +import {library} from "@fortawesome/fontawesome-svg-core" +import {faPlus, faPencil, faTrash} from "@fortawesome/free-solid-svg-icons" +import {FontAwesomeIcon} from "@fortawesome/vue-fontawesome" + +library.add(faPlus, faPencil, faTrash) + +import App from './Agreements.vue' + +createApp(App) + .component("font-awesome-icon", FontAwesomeIcon) + .use(BootstrapVue3) + .mount('#agreements') diff --git a/package.json b/package.json index 163f22a035..209a2cbd44 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,14 @@ "test": "test" }, "dependencies": { - "bootstrap": "^4.5.2", + "@fortawesome/fontawesome-svg-core": "^6.1.0", + "@fortawesome/free-solid-svg-icons": "^6.0.0", + "@fortawesome/vue-fontawesome": "^3.0.0-5", + "@popperjs/core": "^2.11.2", + "babel-core": "^7.0.0-beta.3", + "bootstrap": "^5.1.3", + "bootstrap-vue-3": "^0.1.7", + "css-loader": "^6.6.0", "gulp": "^4.0.2", "gulp-autoprefixer": "^4.0.0", "gulp-concat-po": "^1.0.0", @@ -20,10 +27,15 @@ "js-yaml": "^3.13.1", "lodash": "^4.17.12", "merge-stream": "^2.0.0", - "minimist": "^1.2.5" + "minimist": "^1.2.5", + "style-loader": "^3.3.1", + "vue": "^3.2.31", + "vue-flatpickr-component": "^9" }, "scripts": { "build": "node_modules/.bin/gulp build", + "build_js": "webpack --mode production", + "watch_js": "webpack --mode development --watch", "css": "node_modules/.bin/gulp css", "watch": "node_modules/.bin/gulp watch" }, @@ -43,6 +55,23 @@ "postcss": "^8.4.14", "stylelint-config-standard-scss": "^5.0.0", "stylelint-order": "^5.0.0", - "stylelint": "^14.9.1" + "stylelint": "^14.9.1", + "@babel/core": "^7.17.5", + "@babel/preset-env": "^7.16.11", + "@vue/compiler-sfc": "^3.2.31", + "babel-loader": "^8.2.3", + "babelify": "^10.0.0", + "browserify": "^17.0.0", + "clean-webpack-plugin": "^4.0.0", + "gulp-tap": "^1.0.1", + "html-webpack-plugin": "^5.5.0", + "ts-loader": "^9.2.7", + "typescript": "^4.6.2", + "vinyl-source-stream": "^2.0.0", + "vue-loader": "^17.0.0", + "watchify": "^4.0.0", + "webpack": "^5.69.1", + "webpack-cli": "^4.9.2", + "webpack-dev-server": "^4.7.4" } } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000..88ccffe748 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,4 @@ +{ + "compilerOptions": { + } +} diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000000..efa980de82 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,36 @@ +const { VueLoaderPlugin } = require("vue-loader"); +const autoprefixer = require("autoprefixer"); +const path = require("path"); + +module.exports = { + entry: { + main: "./koha-tmpl/intranet-tmpl/prog/js/vue/main-erm.ts", + }, + output: { + filename: "[name].js", + path: path.resolve(__dirname, "koha-tmpl/intranet-tmpl/prog/js/vue/dist/"), + chunkFilename: "[name].js", + }, + module: { + rules: [ + { + test: /\.vue$/, + loader: "vue-loader", + }, + { + test: /\.ts$/, + loader: 'ts-loader', + options: { + appendTsSuffixTo: [/\.vue$/] + } + }, + { + test: /\.css$/, + use: ['style-loader', 'css-loader'] + } + ], + }, + plugins: [ + new VueLoaderPlugin(), + ], +}; -- 2.39.5