Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-72289

Allow callers to customise the rendered icon of inplace editable elements

    XMLWordPrintable

Details

    • MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • Hide

      Default element icon

      1. Navigate to Courses > Course custom fields in site administration
      2. Press Add new category
      3. Confirm the Edit category name icon is an editing pencil
      4. Edit the value
      5. Confirm the edit icon remains an editing pencil

      Default element icon for selects

      1. Create a new course
      2. Add the Activities block to the course
      3. Open the blocks side bar
      4. Press Forums from the Activities block
      5. Confirm the Email digest type icon is a drop down caret
      6. Edit the value
      7. Confirm the edit icon remains a drop down caret

      Custom element icon

      1. Edit course/format/classes/base.php method inplace_editable_render_section_name to add a custom icon, changing the return value to the following:

                return new \core\output\inplace_editable('format_' . $this->format, $itemtype, $section->id, $editable,
                    $displayvalue, $section->name, $edithint, $editlabel, new \pix_icon('i/calendar', $editlabel));
        

      2. Navigate to your course
      3. Turn editing on
      4. Confirm the New name for topic icon is a calendar
      5. Edit the value
      6. Confirm the edit icon remains a calendar
      Show
      Default element icon Navigate to Courses > Course custom fields in site administration Press Add new category Confirm the Edit category name icon is an editing pencil Edit the value Confirm the edit icon remains an editing pencil Default element icon for selects Create a new course Add the Activities block to the course Open the blocks side bar Press Forums from the Activities block Confirm the Email digest type icon is a drop down caret Edit the value Confirm the edit icon remains a drop down caret Custom element icon Edit course/format/classes/base.php method inplace_editable_render_section_name to add a custom icon, changing the return value to the following: return new \core\output\inplace_editable('format_' . $this->format, $itemtype, $section->id, $editable, $displayvalue, $section->name, $edithint, $editlabel, new \pix_icon('i/calendar', $editlabel)); Navigate to your course Turn editing on Confirm the New name for topic icon is a calendar Edit the value Confirm the edit icon remains a calendar

    Description

      Currently it's hardcoded to t/editstring, core - it would be nice to have flexibility to customise that as part of template context

      https://github.com/moodle/moodle/blob/dc437b51715eaee7e55998ff6eb52f751b19a306/lib/templates/inplace_editable.mustache#L59

      Attachments

        1. MDL-72289_Test Passed.png
          122 kB
          Gladys Basiana
        2. Screenshot 2021-08-05 at 16.23.57.png
          9 kB
          Rafael Lechugo
        3. Screenshot 2021-08-05 at 16.24.17.png
          8 kB
          Rafael Lechugo

        Issue Links

          Activity

            People

              pholden Paul Holden
              pholden Paul Holden
              David Matamoros David Matamoros
              Sara Arjona (@sarjona) Sara Arjona (@sarjona)
              Gladys Basiana Gladys Basiana
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                19/Apr/22

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 hours, 10 minutes
                  2h 10m