Skip to content

Commit

Permalink
mod_collabora: optimize output and settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Grabs committed May 24, 2023
1 parent 5b1d1ca commit 7773b96
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ moodle-mod_collabora
Changes
-------

### v4.2-r2

* 2023-05-25 - Optimize output and settings
* 2023-05-25 - Now showing the file name above the document instead of the title (#39)

### v4.2-r1

* 2023-04-27 - Optimize monologo for document depending icons
Expand Down
7 changes: 1 addition & 6 deletions classes/output/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,10 @@ public function __construct(\cm_info $cm, \stdClass $instance, \mod_collabora\ap

$this->data = new \stdClass();
$this->data->id = $instance->id;
$this->data->name = $collaborafs->display_name() ? format_string($instance->name) : '';
$this->data->filename = $collaborafs->display_name() ? format_string($collaborafs->get_file()->get_filename()) : '';

if ($PAGE->pagelayout == 'embedded') {
$this->data->embedded = true;
} else {
// Description should only be shown in non embedded pages.
if ($collaborafs->display_description() && trim(strip_tags($instance->intro))) {
$this->data->description = format_module_intro('collabora', $instance, $cm->id);
}
}

if ($groupid >= 0) {
Expand Down
2 changes: 2 additions & 0 deletions lang/en/collabora.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
$string['defaultdisplayname'] = 'Default display name';
$string['defaultformat'] = 'Default format';
$string['display'] = 'Display';
$string['display_help'] = 'When "New tab" is selected, the document is displayed in full size in a new tab.';
$string['displaydescription'] = 'Display description';
$string['displayname'] = 'Display name';
$string['displayname_help'] = 'If enabled, the current file name is displayed above the document.';
$string['dnduploadcollabora'] = 'Create a Collabora document';
$string['eventdocumentlocked'] = 'Collaborative document locked';
$string['eventdocumentrepaired'] = 'Collaborative document repaired';
Expand Down
2 changes: 1 addition & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function collabora_extend_settings_navigation(settings_navigation $settingsnav,
global $USER, $PAGE, $CFG;

if (empty($PAGE->cm->context)) {
return; // $PAGE->cm->context = context_module::instance($PAGE->cm->instance);
return;
}

if (has_capability('mod/collabora:repair', $PAGE->cm->context)) {
Expand Down
6 changes: 6 additions & 0 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,26 +102,32 @@ protected function definition() {
// Display section.
$mform->addElement('select', 'display', get_string('display', 'mod_collabora'), collabora_fs::display_menu());
$mform->setDefault('display', $config->defaultdisplay);
$mform->addHelpButton('display', 'display', 'mod_collabora');

// Width.
$mform->addElement('text', 'width', get_string('width', 'mod_collabora'));
$mform->setDefault('width', 0);
$mform->setType('width', PARAM_INT);
$mform->setAdvanced('width');
$mform->disabledIf('width', 'display', 'eq', collabora_fs::DISPLAY_NEW);

// Height.
$mform->addElement('text', 'height', get_string('height', 'mod_collabora'));
$mform->setDefault('height', 0);
$mform->setType('height', PARAM_INT);
$mform->setAdvanced('height');
$mform->disabledIf('height', 'display', 'eq', collabora_fs::DISPLAY_NEW);

// Display activity name.
$mform->addElement('selectyesno', 'displayname', get_string('displayname', 'mod_collabora'));
$mform->setDefault('displayname', $config->defaultdisplayname);
$mform->addHelpButton('displayname', 'displayname', 'mod_collabora');
$mform->disabledIf('displayname', 'display', 'eq', collabora_fs::DISPLAY_NEW);

// Display description.
$mform->addElement('selectyesno', 'displaydescription', get_string('displaydescription', 'mod_collabora'));
$mform->setDefault('displaydescription', $config->defaultdisplaydescription);
$mform->disabledIf('displaydescription', 'display', 'eq', collabora_fs::DISPLAY_NEW);

// Standard sections.
$this->standard_coursemodule_elements();
Expand Down
24 changes: 9 additions & 15 deletions templates/content.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
{
"id" : 46,
"legacy" : 1,
"name" : "Test pad",
"filename" : "Test document",
"loadfileurl": 1,
"description" : "...",
"activitymenu" : "<select><option>1</option><option>2</option></select>",
"lockicon" : "<img alt=\"icon\" src=\"icon.png\">",
"viewurl" : "https://nodomain.local",
Expand All @@ -38,26 +37,21 @@
}

}}
{{^embedded}}
<h2>
{{name}}
</h2>
{{/embedded}}

{{#description}}
<div class="box generalbox mod_introbox py-3">
<div class="no-overflow">
{{{description}}}
</div>
</div>
{{/description}}

{{#hasnotice}}
<div class="alert alert-{{noticetype}} alert-block " role="alert">
{{notice}}
</div>
{{/hasnotice}}

{{^embedded}}
{{# filename}}
<h5>
{{#str}}file{{/str}}: {{.}}
</h5>
{{/ filename}}
{{/embedded}}

{{^warning}}
{{^embedded}}
<button type="button" title="{{#str}}fullscreen, mod_collabora{{/str}}" class="collaboramodal btn btn-primary btn-sm" data-toggle="modal" data-target="#collaboramodal_{{id}}">
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2023042700;
$plugin->release = 'v4.2-r1 (2023-04-27)';
$plugin->version = 2023052400;
$plugin->release = 'v4.2-r2 (2023-05-24)';
$plugin->requires = 2022041200; // Moodle 4.0.
$plugin->component = 'mod_collabora';
$plugin->maturity = MATURITY_STABLE;
6 changes: 6 additions & 0 deletions view.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
];
$PAGE->requires->js_call_amd('mod_collabora/monitorclose', 'init', [$opts]);

// Decide whether or not we show the description.
if ($PAGE->pagelayout == 'embedded' || !$collaborafs->display_description() || !trim(strip_tags($rec->intro))) {
$PAGE->activityheader->set_attrs(array('description' => ''));
}

/** @var \mod_collabora\output\renderer $renderer */
$renderer = $PAGE->get_renderer('mod_collabora');

// Start the output.
Expand Down

0 comments on commit 7773b96

Please sign in to comment.