mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
PHRAS-778 - deactivable documents type permalinks in tools modal
This commit is contained in:

committed by
Benoît Burnichon

parent
a52cfd0d0c
commit
18f9542098
@@ -37,9 +37,22 @@ class ToolsController extends Controller
|
|||||||
|
|
||||||
$metadata = false;
|
$metadata = false;
|
||||||
$record = null;
|
$record = null;
|
||||||
|
$recordAccessibleSubdefs = array();
|
||||||
|
|
||||||
if (count($records) == 1) {
|
if (count($records) == 1) {
|
||||||
$record = $records->first();
|
$record = $records->first();
|
||||||
|
|
||||||
|
// fetch subdef list:
|
||||||
|
$subdefs = $record->get_subdefs();
|
||||||
|
|
||||||
|
foreach ($subdefs as $subdef) {
|
||||||
|
$permalink = $subdef->get_permalink();
|
||||||
|
$recordAccessibleSubdefs[] = array(
|
||||||
|
'name' => $subdef->get_name(),
|
||||||
|
'state' => $permalink->get_is_activated()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$record->isStory()) {
|
if (!$record->isStory()) {
|
||||||
try {
|
try {
|
||||||
$metadata = $this->getExifToolReader()
|
$metadata = $this->getExifToolReader()
|
||||||
@@ -56,6 +69,7 @@ class ToolsController extends Controller
|
|||||||
return $this->render('prod/actions/Tools/index.html.twig', [
|
return $this->render('prod/actions/Tools/index.html.twig', [
|
||||||
'records' => $records,
|
'records' => $records,
|
||||||
'record' => $record,
|
'record' => $record,
|
||||||
|
'recordSubdefs' => $recordAccessibleSubdefs,
|
||||||
'metadatas' => $metadata,
|
'metadatas' => $metadata,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -268,6 +282,44 @@ class ToolsController extends Controller
|
|||||||
return $this->app->json($return);
|
return $this->app->json($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit a record share state
|
||||||
|
* @param Application $app
|
||||||
|
* @param Request $request
|
||||||
|
* @param $base_id
|
||||||
|
* @param $record_id
|
||||||
|
* @return \Symfony\Component\HttpFoundation\JsonResponse
|
||||||
|
*/
|
||||||
|
public function editRecordSharing(Request $request, $base_id, $record_id)
|
||||||
|
{
|
||||||
|
|
||||||
|
$record = new \record_adapter($this->app, \phrasea::sbasFromBas($this->app, $base_id), $record_id);
|
||||||
|
$subdefName = (string)$request->request->get('name');
|
||||||
|
$state = $request->request->get('state') == 'true' ? true : false;
|
||||||
|
$return = ['success' => false, 'message' => 'document type not found'];
|
||||||
|
|
||||||
|
$acl = $this->getAclForUser();
|
||||||
|
if (!$acl->has_access_to_subdef($record, $subdefName) || !$acl->is_admin()) {
|
||||||
|
$this->app->abort(403);
|
||||||
|
}
|
||||||
|
|
||||||
|
$subdefs = $record->get_subdefs();
|
||||||
|
|
||||||
|
foreach ($subdefs as $subdef) {
|
||||||
|
if ($subdef->get_name($subdefName) === $subdefName) {
|
||||||
|
$permalink = $subdef->get_permalink();
|
||||||
|
try {
|
||||||
|
$permalink->set_is_activated($state);
|
||||||
|
$return = ['success' => true, 'state' => $permalink->get_is_activated()];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$return = ['success' => false, 'state' => $permalink->get_is_activated()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->app->json($return);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Reader
|
* @return Reader
|
||||||
*/
|
*/
|
||||||
|
@@ -66,6 +66,8 @@ class Tools implements ControllerProviderInterface, ServiceProviderInterface
|
|||||||
|
|
||||||
$controllers->post('/thumb-extractor/apply/', 'controller.prod.tools:applyThumbnailExtractionAction');
|
$controllers->post('/thumb-extractor/apply/', 'controller.prod.tools:applyThumbnailExtractionAction');
|
||||||
|
|
||||||
|
$controllers->post('/sharing-editor/{base_id}/{record_id}/', 'controller.prod.tools:editRecordSharing');
|
||||||
|
|
||||||
return $controllers;
|
return $controllers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,21 +11,20 @@
|
|||||||
|
|
||||||
{% if url is not empty %}
|
{% if url is not empty %}
|
||||||
<div id="share">
|
<div id="share">
|
||||||
<div id="tweet" class="well-large">
|
<div class="well-large">
|
||||||
<div>
|
<p>
|
||||||
<a href="http://www.twitter.com/home/?status={{ pageurl }}" target="_blank">
|
<a href="http://www.twitter.com/home/?status={{ pageurl }}" target="_blank">
|
||||||
<img src="/skins/icons/twitter.ico" title="share this on twitter" style="vertical-align:middle;padding:0 5px;"/>
|
<img src="/skins/icons/twitter.ico" title="share this on twitter" style="vertical-align:middle;padding:0 5px;"/>
|
||||||
{% trans %}Send to Twitter{% endtrans %}
|
{% trans %}Send to Twitter{% endtrans %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</p>
|
||||||
<div>
|
<p>
|
||||||
<a href="http://www.facebook.com/sharer.php?u={{ pageurl }}" target="_blank">
|
<a href="http://www.facebook.com/sharer.php?u={{ pageurl }}" target="_blank">
|
||||||
<img src="/skins/icons/facebook.ico" title="share on facebook" style="vertical-align:middle;padding:0 5px;"/>
|
<img src="/skins/icons/facebook.ico" title="share on facebook" style="vertical-align:middle;padding:0 5px;"/>
|
||||||
{% trans %}Send to Facebook{% endtrans %}
|
{% trans %}Send to Facebook{% endtrans %}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</p>
|
||||||
</div>
|
|
||||||
<div id="embed" class="well-large">
|
|
||||||
<form action="#">
|
<form action="#">
|
||||||
<label>{% trans %}Resource URL{% endtrans %}</label>
|
<label>{% trans %}Resource URL{% endtrans %}</label>
|
||||||
<input class="input-block-level" readonly="readonly" type="text" value="{{ url }}" />
|
<input class="input-block-level" readonly="readonly" type="text" value="{{ url }}" />
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
<div id='prod-tool-box' class="PNB10">
|
<div id='prod-tool-box' class="PNB10">
|
||||||
|
|
||||||
{# jquery Tabs #}
|
{# jquery Tabs #}
|
||||||
<div id="tool-tabs">
|
<div id="tool-tabs" class="tabs">
|
||||||
{# jquery menu #}
|
{# jquery menu #}
|
||||||
<div>
|
<div>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -59,6 +59,15 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if selectionLength == 1%}
|
||||||
|
{% if recordSubdefs %}
|
||||||
|
<li>
|
||||||
|
<a href="#tools-sharing">
|
||||||
|
{{ "Document Type Sharing" | trans }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{# subdef section #}
|
{# subdef section #}
|
||||||
@@ -299,6 +308,37 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if selectionLength == 1%}
|
||||||
|
{% if recordSubdefs %}
|
||||||
|
<div id="tools-sharing" class="tabBox">
|
||||||
|
<div class="well-large">
|
||||||
|
{% for subdef in recordSubdefs %}
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span6">
|
||||||
|
<span class="status-marker {% if subdef.state %}status-active{% else %}status-inactive
|
||||||
|
{% endif %}"></span>{{ subdef.name }}
|
||||||
|
</div>
|
||||||
|
<div class="span6">
|
||||||
|
<p class="text-right">
|
||||||
|
{% if subdef.state %}
|
||||||
|
<button type="button"
|
||||||
|
class="stateChange_button btn btn-inverse text-right"
|
||||||
|
data-name="{{ subdef.name }}"
|
||||||
|
data-state="{{ subdef.state }}">{{ "Disable document type sharing" | trans }}</button>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
<button type="button" class="stateChange_button btn btn-inverse text-right"
|
||||||
|
data-name="{{ subdef.name }}"
|
||||||
|
data-state="{{ subdef.state }}">{{ "Enable document type sharing" | trans }}</button>
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{# hidden iframe to handle upload #}
|
{# hidden iframe to handle upload #}
|
||||||
@@ -315,10 +355,9 @@
|
|||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
var scope = $("#prod-tool-box");
|
var scope = $("#prod-tool-box");
|
||||||
|
var tabs = $("#tool-tabs", scope).tabs();
|
||||||
var width = 0;
|
var width = 0;
|
||||||
|
|
||||||
$("#tool-tabs", scope).tabs();
|
|
||||||
|
|
||||||
$(".iframe_submiter", scope).bind("click", function(){
|
$(".iframe_submiter", scope).bind("click", function(){
|
||||||
var form = $(this).closest("form");
|
var form = $(this).closest("form");
|
||||||
form.submit();
|
form.submit();
|
||||||
@@ -585,5 +624,30 @@ $(document).ready(function(){
|
|||||||
//not supported
|
//not supported
|
||||||
$("#thumbExtractor").empty().append(language.browserFeatureSupport);
|
$("#thumbExtractor").empty().append(language.browserFeatureSupport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{% if selectionLength == 1%}
|
||||||
|
$('#tools-sharing .stateChange_button').bind('click',function(event){
|
||||||
|
var $btn = $(event.currentTarget),
|
||||||
|
state = true;
|
||||||
|
|
||||||
|
// inverse state
|
||||||
|
if( $btn.data('state') == 1) {
|
||||||
|
state = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// submit changes
|
||||||
|
$.post('tools/sharing-editor/{{record.get_base_id}}/{{record.get_record_id}}/', {
|
||||||
|
name: $btn.data('name'),
|
||||||
|
state: state
|
||||||
|
}).done(function(data) {
|
||||||
|
// self reload tab with current active tab:
|
||||||
|
var activeTab = tabs.tabs('option', 'active');
|
||||||
|
toolREFACTOR($dialog.getOption('contextArgs'), activeTab);
|
||||||
|
}).error(function(err) {
|
||||||
|
alert('forbidden action')
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
{% endif %}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@@ -4997,3 +4997,27 @@ ui-dialog-titlebar {
|
|||||||
width: 26px;
|
width: 26px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.status-marker {
|
||||||
|
line-height: 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 7px;
|
||||||
|
height: 7px;
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 4px;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
.status-marker.status-active{
|
||||||
|
background-color: #58d5b5;
|
||||||
|
box-shadow: 0 0 6px #69fcd6;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-marker.status-inactive {
|
||||||
|
background-color: #aaaaaa;
|
||||||
|
box-shadow: inset 1px 1px 2px 0px rgba(0,0,0,0.7);
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
@@ -4889,3 +4889,27 @@ ui-dialog-titlebar {
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
background: #999;
|
background: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.status-marker {
|
||||||
|
line-height: 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 7px;
|
||||||
|
height: 7px;
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 4px;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
.status-marker.status-active{
|
||||||
|
background-color: #58d5b5;
|
||||||
|
box-shadow: 0 0 6px #69fcd6;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-marker.status-inactive {
|
||||||
|
background-color: #aaaaaa;
|
||||||
|
box-shadow: inset 1px 1px 2px 0px rgba(0,0,0,0.7);
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
@@ -1875,7 +1875,7 @@ function feedbackThis(sstt_id, lst, story) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function toolREFACTOR(datas) {
|
function toolREFACTOR(datas, activeTab) {
|
||||||
|
|
||||||
var dialog = p4.Dialog.Create({
|
var dialog = p4.Dialog.Create({
|
||||||
size: 'Medium',
|
size: 'Medium',
|
||||||
@@ -1887,10 +1887,16 @@ function toolREFACTOR(datas) {
|
|||||||
, datas
|
, datas
|
||||||
, function (data) {
|
, function (data) {
|
||||||
dialog.setContent(data);
|
dialog.setContent(data);
|
||||||
|
dialog.setOption('contextArgs', datas);
|
||||||
|
var tabs = $('.tabs', dialog.getDomElement()).tabs();
|
||||||
|
|
||||||
|
// activate tab if exists:
|
||||||
|
if( activeTab !== undefined ) {
|
||||||
|
tabs.tabs('option', 'active', activeTab);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function activeIcons() {
|
function activeIcons() {
|
||||||
|
Reference in New Issue
Block a user