diff --git a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php index 1917d3f581..e88852d5b8 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/ToolsController.php @@ -37,9 +37,22 @@ class ToolsController extends Controller $metadata = false; $record = null; + $recordAccessibleSubdefs = array(); if (count($records) == 1) { $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()) { try { $metadata = $this->getExifToolReader() @@ -56,6 +69,7 @@ class ToolsController extends Controller return $this->render('prod/actions/Tools/index.html.twig', [ 'records' => $records, 'record' => $record, + 'recordSubdefs' => $recordAccessibleSubdefs, 'metadatas' => $metadata, ]); } @@ -268,6 +282,44 @@ class ToolsController extends Controller 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 */ diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Prod/Tools.php b/lib/Alchemy/Phrasea/ControllerProvider/Prod/Tools.php index d908cbae06..580ea49bb3 100644 --- a/lib/Alchemy/Phrasea/ControllerProvider/Prod/Tools.php +++ b/lib/Alchemy/Phrasea/ControllerProvider/Prod/Tools.php @@ -66,6 +66,8 @@ class Tools implements ControllerProviderInterface, ServiceProviderInterface $controllers->post('/thumb-extractor/apply/', 'controller.prod.tools:applyThumbnailExtractionAction'); + $controllers->post('/sharing-editor/{base_id}/{record_id}/', 'controller.prod.tools:editRecordSharing'); + return $controllers; } } diff --git a/templates/web/prod/Share/record.html.twig b/templates/web/prod/Share/record.html.twig index 2f9621b439..c0b5776e9a 100644 --- a/templates/web/prod/Share/record.html.twig +++ b/templates/web/prod/Share/record.html.twig @@ -11,21 +11,20 @@ {% if url is not empty %}
-
-
+ -
+

+

{% trans %}Send to Facebook{% endtrans %} -

-
-
+

+
diff --git a/templates/web/prod/actions/Tools/index.html.twig b/templates/web/prod/actions/Tools/index.html.twig index 3ce3e929e7..a9e10a791a 100644 --- a/templates/web/prod/actions/Tools/index.html.twig +++ b/templates/web/prod/actions/Tools/index.html.twig @@ -20,7 +20,7 @@
{# jquery Tabs #} -
+
{# jquery menu #}
{# subdef section #} @@ -299,6 +308,37 @@
{% endfor %} {% endif %} + {% if selectionLength == 1%} + {% if recordSubdefs %} +
+
+ {% for subdef in recordSubdefs %} +
+
+ {{ subdef.name }} +
+
+

+ {% if subdef.state %} + + + {% else %} + + {% endif %} +

+
+
+ {% endfor %} +
+
+ {% endif %} + {% endif %}
{# hidden iframe to handle upload #} @@ -315,10 +355,9 @@ $(document).ready(function(){ var scope = $("#prod-tool-box"); + var tabs = $("#tool-tabs", scope).tabs(); var width = 0; - $("#tool-tabs", scope).tabs(); - $(".iframe_submiter", scope).bind("click", function(){ var form = $(this).closest("form"); form.submit(); @@ -585,5 +624,30 @@ $(document).ready(function(){ //not supported $("#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 %} }); diff --git a/www/skins/prod/000000/prodcolor.css b/www/skins/prod/000000/prodcolor.css index 8843b6999c..7bee0b2eda 100644 --- a/www/skins/prod/000000/prodcolor.css +++ b/www/skins/prod/000000/prodcolor.css @@ -4997,3 +4997,27 @@ ui-dialog-titlebar { 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; +} diff --git a/www/skins/prod/959595/prodcolor.css b/www/skins/prod/959595/prodcolor.css index 44edfafe6d..51121626d8 100644 --- a/www/skins/prod/959595/prodcolor.css +++ b/www/skins/prod/959595/prodcolor.css @@ -4889,3 +4889,27 @@ ui-dialog-titlebar { color: #fff; 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; +} diff --git a/www/skins/prod/jquery.main-prod.js b/www/skins/prod/jquery.main-prod.js index 1784b02112..76daf20e0b 100644 --- a/www/skins/prod/jquery.main-prod.js +++ b/www/skins/prod/jquery.main-prod.js @@ -1875,7 +1875,7 @@ function feedbackThis(sstt_id, lst, story) { }); } -function toolREFACTOR(datas) { +function toolREFACTOR(datas, activeTab) { var dialog = p4.Dialog.Create({ size: 'Medium', @@ -1887,10 +1887,16 @@ function toolREFACTOR(datas) { , datas , function (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; } ); - } function activeIcons() {