Skip to content
Permalink
Browse files

very basic forceDraft

  • Loading branch information...
joshinat0r committed Aug 29, 2019
1 parent f006a4f commit c44f4423563fc36cf71daa313faf29dff888269a
Showing with 63 additions and 1 deletion.
  1. +18 −0 README.md
  2. +6 −1 admin.php
  3. +39 −0 views/partials/fake-entry-aside.php
@@ -45,6 +45,24 @@ if you change the field later you may need to manually update all existing colle

[![Moderation Addon](http://img.youtube.com/vi/LywGxJqUJkg/0.jpg)](http://www.youtube.com/watch?v=LywGxJqUJkg "Moderation Addon")

## Force drafts for a specific user group

If you want to deny a user group the right to publish/unpublish entries, then provide `moderation.forceDraft` for the group in question.

Groups with this var wont get a dropdown for the moderation status, they get the `fake-entry-aside.php`-view in the sidebar.

```
'groups' => [
'contributor' => [
...
'$vars' => [
'moderation.forceDraft' => true
],
...
]
],
```

## Copyright and license

Copyright 2018 pauloamgomes under the MIT license.
@@ -9,7 +9,12 @@
* Add moderation markup to collections sidebar.
*/
$this->on('collections.entry.aside', function() {
$this->renderView("moderation:views/partials/entry-aside.php");
// if moderation.forceDraft then serve 'fake-entry-aside.php'
if ($this->module('cockpit')->getGroupVar('moderation.forceDraft')) {
$this->renderView("moderation:views/partials/fake-entry-aside.php");
} else {
$this->renderView("moderation:views/partials/entry-aside.php");
}
});
/**
@@ -0,0 +1,39 @@
<div class="uk-margin moderation-status" if="{field && field.length && moderation_field}">
<div class="uk-width-1-1 uk-form-select uk-moderation-element uk-moderation-{ entry[moderation_field] }">
<label class="uk-text-small">@lang('Submit as')</label>
<div class="uk-margin-small-top">
<span class="uk-badge uk-badge-outline">
<i if="{entry[moderation_field] == 'Draft'}" class="uk-icon-pencil"></i>
@lang("{entry[moderation_field]}")
</span>
</div>
</div>
</div>

<script>
var $this = this;
$this.moderation_field = 'status';
this.on('mount', function() {
$this.field = this.collection.fields.filter(function(definition) {
return definition.type === 'moderation';
});
if (!$this.field.length || $this.field[0].name === undefined) {
return;
}
$this.moderation_field = $this.field[0].name;
$this.entry[$this.moderation_field] = 'Draft';
window.setTimeout(function() {
sidebar = document.querySelector('.uk-width-medium-1-4.uk-flex-order-first');
sidebar.insertBefore(document.querySelector('.moderation-status'), sidebar.childNodes[0]);
}, 50);
$this.update();
});
</script>

0 comments on commit c44f442

Please sign in to comment.
You can’t perform that action at this time.