From 2140d3e55c10a38d4f14a20e203ea701120ff8f5 Mon Sep 17 00:00:00 2001 From: Huong Nguyen Date: Wed, 23 Jun 2021 09:38:58 +0700 Subject: [PATCH] MDL-71771 core_calendar: Convert the calendar footer buttons to links --- .../external/footer_options_exporter.php | 35 +++++++++---------- calendar/templates/footer_options.mustache | 20 ++++++----- calendar/tests/behat/calendar_import.feature | 6 ++-- calendar/tests/behat/export.feature | 12 +++---- theme/boost/scss/moodle/calendar.scss | 13 +++++-- theme/boost/style/moodle.css | 9 +++-- theme/classic/style/moodle.css | 9 +++-- 7 files changed, 62 insertions(+), 42 deletions(-) diff --git a/calendar/classes/external/footer_options_exporter.php b/calendar/classes/external/footer_options_exporter.php index da7b69de585..51a61bac2e6 100644 --- a/calendar/classes/external/footer_options_exporter.php +++ b/calendar/classes/external/footer_options_exporter.php @@ -67,26 +67,26 @@ class footer_options_exporter extends exporter { } /** - * Get the export calendar button. + * Get the export calendar link. * - * @return \single_button The export calendar button html. + * @return string The export calendar hyperlink. */ - protected function get_export_calendar_button() { + protected function get_export_calendar_link(): string { $exportcalendarurl = new moodle_url('/calendar/export.php', $this->get_link_params()); - return new \single_button($exportcalendarurl, get_string('exportcalendar', 'calendar'), 'get'); + return $exportcalendarurl->out(true); } /** - * Get manage subscription button. + * Get manage subscription link. * - * @return string The manage subscription button html. + * @return string|null The manage subscription hyperlink. */ - protected function get_manage_subscriptions_button() { + protected function get_manage_subscriptions_link(): ?string { if (calendar_user_can_add_event($this->calendar->course)) { $managesubscriptionurl = new moodle_url('/calendar/managesubscriptions.php', $this->get_link_params()); - return new \single_button($managesubscriptionurl, - get_string('managesubscriptions', 'calendar'), 'get'); + return $managesubscriptionurl->out(true); } + return null; } /** @@ -117,11 +117,9 @@ class footer_options_exporter extends exporter { $values = new stdClass(); if (!empty($CFG->enablecalendarexport)) { - if ($exportbutton = $this->get_export_calendar_button()) { - $values->exportcalendarbutton = $exportbutton->export_for_template($output); - } - if ($managesubscriptionbutton = $this->get_manage_subscriptions_button()) { - $values->managesubscriptionbutton = $managesubscriptionbutton->export_for_template($output); + $values->exportcalendarlink = $this->get_export_calendar_link(); + if ($managesubscriptionlink = $this->get_manage_subscriptions_link()) { + $values->managesubscriptionlink = $managesubscriptionlink; } } @@ -135,12 +133,11 @@ class footer_options_exporter extends exporter { */ public static function define_other_properties() { return array( - 'exportcalendarbutton' => [ - 'type' => PARAM_RAW, - 'default' => null, + 'exportcalendarlink' => [ + 'type' => PARAM_URL ], - 'managesubscriptionbutton' => [ - 'type' => PARAM_RAW, + 'managesubscriptionlink' => [ + 'type' => PARAM_URL, 'default' => null, ], ); diff --git a/calendar/templates/footer_options.mustache b/calendar/templates/footer_options.mustache index 427919ebdcd..3618e378358 100644 --- a/calendar/templates/footer_options.mustache +++ b/calendar/templates/footer_options.mustache @@ -21,15 +21,19 @@ Example context (json): { - "exportcalendarbutton": "", - "managesubscriptionbutton": "" + "exportcalendarlink": "http://abc.com/calendar/export.php?course=1", + "managesubscriptionlink": "http://abc.com/calendar/managesubscriptions.php?course=1" } }}
- {{#exportcalendarbutton}} - {{> core/single_button }} - {{/exportcalendarbutton}} - {{#managesubscriptionbutton}} - {{> core/single_button }} - {{/managesubscriptionbutton}} + {{#exportcalendarlink}} + + {{#str}}exportcalendar, calendar{{/str}} + + {{/exportcalendarlink}} + {{#managesubscriptionlink}} + + {{#str}}managesubscriptions, calendar{{/str}} + + {{/managesubscriptionlink}}
diff --git a/calendar/tests/behat/calendar_import.feature b/calendar/tests/behat/calendar_import.feature index 2ad027a7b7b..945c49ae6ed 100644 --- a/calendar/tests/behat/calendar_import.feature +++ b/calendar/tests/behat/calendar_import.feature @@ -18,7 +18,7 @@ Feature: Import and edit calendar events Scenario: Import then edit a calendar event. Given I log in as "teacher1" And I view the calendar for "1" "2016" - And I press "Manage subscriptions" + And I click on "Manage subscriptions" "link" And I set the following fields to these values: | Calendar name | Test Import | | Import from | Calendar file (.ics) | @@ -42,7 +42,7 @@ Feature: Import and edit calendar events Then I should see "Event on 2-20-2017" And I should see "Event on 2-25-2017" And I should not see "Event on 2-15-2017" - And I press "Manage subscriptions" + And I click on "Manage subscriptions" "link" And I press "Remove" And I view the calendar for "2" "2017" And I should not see "Event on 2-25-2017" @@ -51,7 +51,7 @@ Feature: Import and edit calendar events Scenario: Import events using different event types. Given I log in as "admin" And I view the calendar for "1" "2016" - And I press "Manage subscriptions" + And I click on "Manage subscriptions" "link" And I set the following fields to these values: | Calendar name | Test Import | | Import from | Calendar file (.ics) | diff --git a/calendar/tests/behat/export.feature b/calendar/tests/behat/export.feature index 00fb3a75f26..a26439f71f1 100644 --- a/calendar/tests/behat/export.feature +++ b/calendar/tests/behat/export.feature @@ -18,7 +18,7 @@ Feature: Export calendar events Scenario: Viewing calendar export options Given I follow "This month" - When I click on "Export calendar" "button" + When I click on "Export calendar" "link" Then I should see "All events" And I should see "Events related to courses" And I should see "Events related to groups" @@ -26,7 +26,7 @@ Feature: Export calendar events Scenario: Generating calendar URL for all events Given I follow "This month" - And I click on "Export calendar" "button" + And I click on "Export calendar" "link" And I set the field "All events" to "1" And I set the field "Recent and next 60 days" to "1" When I click on "Get calendar URL" "button" @@ -34,7 +34,7 @@ Feature: Export calendar events Scenario: Generating calendar URL for course events Given I follow "This month" - And I click on "Export calendar" "button" + And I click on "Export calendar" "link" And I set the field "Events related to courses" to "1" And I set the field "Recent and next 60 days" to "1" When I click on "Get calendar URL" "button" @@ -42,7 +42,7 @@ Feature: Export calendar events Scenario: Generating calendar URL for group events Given I follow "This month" - And I click on "Export calendar" "button" + And I click on "Export calendar" "link" And I set the field "Events related to groups" to "1" And I set the field "Recent and next 60 days" to "1" When I click on "Get calendar URL" "button" @@ -50,7 +50,7 @@ Feature: Export calendar events Scenario: Generating calendar URL for category events Given I follow "This month" - And I click on "Export calendar" "button" + And I click on "Export calendar" "link" And I set the field "Events related to categories" to "1" And I set the field "Recent and next 60 days" to "1" When I click on "Get calendar URL" "button" @@ -58,7 +58,7 @@ Feature: Export calendar events Scenario: Generating calendar URL for user events Given I follow "This month" - And I click on "Export calendar" "button" + And I click on "Export calendar" "link" And I set the field "My personal events" to "1" And I set the field "Recent and next 60 days" to "1" When I click on "Get calendar URL" "button" diff --git a/theme/boost/scss/moodle/calendar.scss b/theme/boost/scss/moodle/calendar.scss index 5d00eaf2e3e..937f212cf03 100644 --- a/theme/boost/scss/moodle/calendar.scss +++ b/theme/boost/scss/moodle/calendar.scss @@ -119,8 +119,17 @@ $calendarEventColor: #0d5ca1 !default; padding: 0; .bottom { - text-align: center; - padding: 5px 0 0 0; + text-align: left; + padding: 20px 0 0 20px; + + span.export-link:after { + content: "\2022"; + color: $blue; + } + + span.export-link:last-child:after { + content: none; + } } .heightcontainer { diff --git a/theme/boost/style/moodle.css b/theme/boost/style/moodle.css index 4cd39038e7c..31da097ab24 100644 --- a/theme/boost/style/moodle.css +++ b/theme/boost/style/moodle.css @@ -12894,8 +12894,13 @@ input[disabled] { vertical-align: top; padding: 0; } .path-calendar .maincalendar .bottom { - text-align: center; - padding: 5px 0 0 0; } + text-align: left; + padding: 20px 0 0 20px; } + .path-calendar .maincalendar .bottom span.export-link:after { + content: "\2022"; + color: #0f6fc5; } + .path-calendar .maincalendar .bottom span.export-link:last-child:after { + content: none; } .path-calendar .maincalendar .heightcontainer { height: 100%; position: relative; } diff --git a/theme/classic/style/moodle.css b/theme/classic/style/moodle.css index d444630f39d..a545b1d3000 100644 --- a/theme/classic/style/moodle.css +++ b/theme/classic/style/moodle.css @@ -13116,8 +13116,13 @@ input[disabled] { vertical-align: top; padding: 0; } .path-calendar .maincalendar .bottom { - text-align: center; - padding: 5px 0 0 0; } + text-align: left; + padding: 20px 0 0 20px; } + .path-calendar .maincalendar .bottom span.export-link:after { + content: "\2022"; + color: #0f6fc5; } + .path-calendar .maincalendar .bottom span.export-link:last-child:after { + content: none; } .path-calendar .maincalendar .heightcontainer { height: 100%; position: relative; }