Giter VIP home page Giter VIP logo

oc-revisionable-plugin's Introduction

Revisionable

This plugin add RevisionableController a Controller Behavior for display revisions history on the backend

Setup for a model

  1. Ensure your model have the Revisionable Trait
  2. Add behavior \Inetis\Revisionable\Behaviors\RevisionableController::class to your Controller
    This will make available the list of model changes at this URL vendor/plugin/model/history/$id
  3. Add "Show history" button on Preview (preview.htm) file of your controller
    <a href="<?= Backend::url('vendor/plugin/model/history/' . $formModel->id) ?>"
       class="btn btn-default oc-icon-history">
        <?= e(trans('inetis.revisionable::lang.btn_show_history')) ?>
    </a>

Showing who made the change

If your revisions also store the user id (see documentation) you can register the relation in your Plugin.php file for that the name of the user be displayed in history table.

use October\Rain\Database\Models\Revision;

class Plugin extends PluginBase
{
    // [ ... ]

    public function boot()
    {
        // [ ... ]

        Revision::extend(function (Revision $revision) {

            // If you use Backend user
            $revision->belongsTo['user'] = [\Backend\Models\User::class];

            // or if you use Frontend user
            $revision->belongsTo['user'] = [\RainLab\User\Models\User::class];

        });
    }
}

Customize the rendering

You can override the default rendering of the history page (plugins/inetis/revisionable/behaviors/revisionablecontroller/partials/_container.htm) by creating a _revisionable_container.htm file in the views directory of your controller.

Use custom timezone

By default the Backend user timezone is used but you can override that by creating a file in /config/inetis/revisionable/config.php with you desired timezone (see below)

<?php

return [

    /**
     * Timezone used for display modification date 
     * by default use Backend timezone : \Backend\Models\Preference::get('timezone')     
     * but you can override it to a regional timezone e.g.: 'Europe/Zurich'
     */
    'timezone' => 'Europe/Zurich',

];

oc-revisionable-plugin's People

Contributors

chvuagniaux avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.