Skip to content

Commit

Permalink
Merge branch 'MDL-71771-master' of git://github.com/HuongNV13/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jul 1, 2021
2 parents 1543d60 + 2140d3e commit 1cb50a3
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 42 deletions.
35 changes: 16 additions & 19 deletions calendar/classes/external/footer_options_exporter.php
Expand Up @@ -67,26 +67,26 @@ public function __construct(\calendar_information $calendar, $userid, $token) {
}

/**
* 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;
}

/**
Expand Down Expand Up @@ -117,11 +117,9 @@ protected function get_other_values(renderer_base $output) {
$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;
}
}

Expand All @@ -135,12 +133,11 @@ protected function get_other_values(renderer_base $output) {
*/
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,
],
);
Expand Down
20 changes: 12 additions & 8 deletions calendar/templates/footer_options.mustache
Expand Up @@ -21,15 +21,19 @@
Example context (json):
{
"exportcalendarbutton": "<button class='btn btn-secondary'>Export calendar</button>",
"managesubscriptionbutton": "<button class='btn btn-secondary'>Manage subscriptions</button>"
"exportcalendarlink": "http://abc.com/calendar/export.php?course=1",
"managesubscriptionlink": "http://abc.com/calendar/managesubscriptions.php?course=1"
}
}}
<div class="bottom">
{{#exportcalendarbutton}}
{{> core/single_button }}
{{/exportcalendarbutton}}
{{#managesubscriptionbutton}}
{{> core/single_button }}
{{/managesubscriptionbutton}}
{{#exportcalendarlink}}
<span class="export-link">
<a href="{{.}}" title={{#quote}}{{#str}}exportcalendar, calendar{{/str}}{{/quote}}>{{#str}}exportcalendar, calendar{{/str}}</a>
</span>
{{/exportcalendarlink}}
{{#managesubscriptionlink}}
<span class="export-link">
<a href="{{.}}" title={{#quote}}{{#str}}managesubscriptions, calendar{{/str}}{{/quote}}>{{#str}}managesubscriptions, calendar{{/str}}</a>
</span>
{{/managesubscriptionlink}}
</div>
6 changes: 3 additions & 3 deletions calendar/tests/behat/calendar_import.feature
Expand Up @@ -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) |
Expand All @@ -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"
Expand All @@ -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) |
Expand Down
12 changes: 6 additions & 6 deletions calendar/tests/behat/export.feature
Expand Up @@ -18,47 +18,47 @@ 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"
And I should see "My personal 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"
Then I should see "&preset_what=all&"

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"
Then I should see "&preset_what=courses&"

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"
Then I should see "&preset_what=groups&"

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"
Then I should see "&preset_what=categories&"

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"
Expand Down
13 changes: 11 additions & 2 deletions theme/boost/scss/moodle/calendar.scss
Expand Up @@ -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 {
Expand Down
9 changes: 7 additions & 2 deletions theme/boost/style/moodle.css
Expand Up @@ -12891,8 +12891,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; }
Expand Down
9 changes: 7 additions & 2 deletions theme/classic/style/moodle.css
Expand Up @@ -13113,8 +13113,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; }
Expand Down

0 comments on commit 1cb50a3

Please sign in to comment.