Skip to content

Commit

Permalink
Issue #69: Move custom fields config to the CMS config.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypha committed Oct 9, 2023
1 parent f17c02b commit 4a55e26
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 76 deletions.
27 changes: 16 additions & 11 deletions classes/local/datasource/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace mod_cms\local\datasource;

use core_customfield\{category_controller, field};
use core_customfield\{category_controller, field, output\management};
use mod_cms\customfield\cmsfield_handler;
use mod_cms\helper;
use mod_cms\local\lib;
Expand Down Expand Up @@ -95,18 +95,23 @@ protected function get_sample($field): string {
}

/**
* Return a action link to add to the CMS type table.
* Add fields to the CMS type config form.
*
* @return string|null
* @param \MoodleQuickForm $mform
*/
public function config_action_link(): ?string {
// Link for custom fields.
return helper::format_icon_link(
new \moodle_url($this->cfhandler->get_configuration_url()),
't/index_drawer',
get_string('fields:custom_fields', 'mod_cms'),
null
);
public function config_form_definition(\MoodleQuickForm $mform) {
global $PAGE;

// Add a heading.
$mform->addElement('header', 'fields_heading', get_string('fields:config:header', 'mod_cms'));

$output = $PAGE->get_renderer('core_customfield');
$outputpage = new management($this->cfhandler);

// This may not fill the screen. Add '.form-control-static {width: 100%}' to custom CSS.
$html = $output->render($outputpage);

$mform->addElement('static', 'fields', get_string('fields:config:columns', 'mod_cms'), $html);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/local/datasource/userlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function config_form_definition(\MoodleQuickForm $mform) {
// This may not fill the screen. Add '.form-control-static {width: 100%}' to custom CSS.
$html = $output->render($outputpage);

$mform->addElement('static', 'userlist', 'List columns', $html);
$mform->addElement('static', 'userlist', get_string('userlist:config:columns', 'mod_cms'), $html);
}

/**
Expand Down
63 changes: 0 additions & 63 deletions customfield.php

This file was deleted.

3 changes: 3 additions & 0 deletions lang/en/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@

// Custom field datasource strings.
$string['fields:custom_fields'] = 'Custom fields';
$string['fields:config:columns'] = 'Fields and categories';
$string['fields:config:header'] = 'Custom field settings';
$string['fields:sample_text'] = 'text';
$string['fields:sample_time'] = 'Thursday, 15 June 2023, 12:00 AM';

// User list datasource strings.
$string['userlist:config:columns'] = 'User list columns';
$string['userlist:config:header'] = 'User list settings';
$string['userlist:displayname'] = 'User list';
$string['userlist:listdata'] = 'List data';
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

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

$plugin->version = 2023100300;
$plugin->version = 2023100900;
$plugin->requires = 2020061500; // Moodle 3.9.0 and above.
$plugin->supported = [39, 401]; // Moodle 3.9 to 4.1 inclusive.
$plugin->component = 'mod_cms';
Expand Down

0 comments on commit 4a55e26

Please sign in to comment.