Commit 70662bda authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Robert Lyon
Browse files

Bug 1891949: don't use saved height for signoff blocks

and add a function to make it possible for other blocks
that have different contents in edit/view modes
to ignore the height and let the gridstack library resize

behatnotneeded

Change-Id: I471e35d3881d7f3654cd508f7de31ebfdedfbc5c
(cherry picked from commit db35d4e8)
parent a5996bf0
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -138,4 +138,8 @@ class PluginBlocktypeSignoff extends MaharaCoreBlocktype {
        ensure_record_exists('view_signoff_verify', (object) array('view' => $viewid), (object) array('view' => $viewid), 'id', true);
        return $configdata;
    }

    public static function set_block_height_on_load() {
        return true;
    }
}
+12 −0
Original line number Diff line number Diff line
@@ -777,6 +777,18 @@ EOF;
    public static function display_for_roles($roles) {
        return !(count($roles) == 1 && $roles[0] == 'peer');
    }

    /**
     * Defines if the block has to always be resized on load
     *
     * This method should be overridden in the child class, if the block
     * content is different when viewing than when editing
     *
     * @return boolean whether the height set on the DB should be ignored
     */
    public static function set_block_height_on_load() {
        return false;
    }
}


+11 −1
Original line number Diff line number Diff line
@@ -2092,9 +2092,19 @@ class View {
            else {
                $result = $blockinstance->render_viewing($exporting, $versioning);
            }
            // check if the height needs to be defined when loading the block
            // this will happen when the block content in edit mode is different from
            // the block content in view mode
            $classname = generate_class_name('blocktype', $blockinstance->get('blocktype'));
            if (call_static_method($classname, 'set_block_height_on_load', $blockinstance)) {
                $block['height'] = 1;
            }
            else {
                $block['height'] = $blockinstance->get('height');
            }

            $block['content'] = $result;
            $block['width'] = $blockinstance->get('width');
            $block['height'] = $blockinstance->get('height');
            $block['positionx'] = $blockinstance->get('positionx');
            $block['positiony'] = $blockinstance->get('positiony');
            $block['row'] = $blockinstance->get('row');