diff --git a/plugins/manager/assets/widget.js b/plugins/manager/assets/widget.js index b6d713ebe..3636671d8 100644 --- a/plugins/manager/assets/widget.js +++ b/plugins/manager/assets/widget.js @@ -6,6 +6,8 @@ $(document).on('rex:ready',function() { let link = this.dataset.link; let widget_type = this.dataset.widget_type; let field_name = this.dataset.field_name; + let _csrf_token = this.dataset.csrf_token; + let value = this.dataset.value; $(this).find("a").each(function () { @@ -21,6 +23,34 @@ $(document).on('rex:ready',function() { }; } + // add + if (this.classList.contains('yform-dataset-widget-add')) { + this.onclick = function () { + let newWindowLink = link + '&_csrf_token='+ _csrf_token +'&func=add&rex_yform_manager_opener[id]='+id+'&rex_yform_manager_opener[field]='+field_name+'&rex_yform_manager_opener[multiple]='+multiple; + return newWindow( id, newWindowLink, 1200,800,',status=yes,resizable=yes'); + }; + } + + // view + if (value !== '' && this.classList.contains('yform-dataset-widget-view')) { + this.onclick = function () { + let dataId = value; + if (multiple === 1) { + let viewObject = document.querySelector('#yform-dataset-view-'+id); + for (let position = 0; position < viewObject.options.length; position++) { + if (viewObject.options[position].selected) { + dataId = viewObject.options[position].value; + break; + } + } + + } + + let newWindowLink = link + '&_csrf_token='+ _csrf_token +'&func=edit&data_id=' + dataId + '&rex_yform_manager_opener[id]='+id+'&rex_yform_manager_opener[field]='+field_name+'&rex_yform_manager_opener[multiple]='+multiple; + return newWindow( id, newWindowLink, 1200,800,',status=yes,resizable=yes'); + }; + } + // open if (this.classList.contains('yform-dataset-widget-open')) { this.onclick = function () { diff --git a/plugins/manager/lang/de_de.lang b/plugins/manager/lang/de_de.lang index 9fd0f29c3..9dcc164b4 100644 --- a/plugins/manager/lang/de_de.lang +++ b/plugins/manager/lang/de_de.lang @@ -20,8 +20,11 @@ yform_relation_move_first_data = Ausgewählten Datensatz an den Anfang verschieb yform_relation_move_up_data = Ausgewählten Datensatz nach oben verschieben yform_relation_move_down_data = Ausgewählten Datensatz nach unten verschieben yform_relation_move_last_data = Ausgewählten Datensatz an das Ende verschieben +yform_relation_add_entry = Datensatz hinzufügen yform_relation_choose_entry = Datensatz auswählen yform_relation_delete_entry = Ausgewählten Datensatz löschen +yform_relation_no_entry = Kein Datensatz zugewiesen +yform_relation_view_entry = Datensatz ansehen yform_relation_first_create_data = Bitte zunächst diesen Datensatz erstellen yform_relation_edit_relations = Verknüpfungen verwalten diff --git a/plugins/manager/lang/en_gb.lang b/plugins/manager/lang/en_gb.lang index 468e7df92..24dfbea8d 100644 --- a/plugins/manager/lang/en_gb.lang +++ b/plugins/manager/lang/en_gb.lang @@ -18,8 +18,11 @@ yform_relation_move_first_data = Move selected entry to the top yform_relation_move_up_data = Move selected entry up yform_relation_move_down_data = Move selected entry down yform_relation_move_last_data = Move selected entry to the bottom +yform_relation_add_entry = Add record yform_relation_choose_entry = Select record yform_relation_delete_entry = Delete selected record +yform_relation_no_entry = No record selected +yform_relation_view_entry = View record yform_relation_first_create_data = Please first create this record yform_relation_edit_relations = Edit relations diff --git a/plugins/manager/lib/var_yform_dataset.php b/plugins/manager/lib/var_yform_dataset.php index 5f37bdbc6..3d001c69f 100644 --- a/plugins/manager/lib/var_yform_dataset.php +++ b/plugins/manager/lib/var_yform_dataset.php @@ -115,6 +115,11 @@ public static function getMultipleWidget($id, $name, $value, array $args = []) $select->addOption($option['name'], $option['id']); } + $viewButton = ''; + if ('' === $value) { + $viewButton = ''; + } + $e = []; $e['field'] = $select->get() . ' '; @@ -125,13 +130,15 @@ public static function getMultipleWidget($id, $name, $value, array $args = []) '; $e['functionButtons'] = ' - + + - '; + ' . $viewButton; $e['before'] = '
'; $e['after'] = '
'; @@ -150,18 +157,26 @@ public static function getSingleWidget($id, $name, $value, array $args = []) $dataset_view_id = 'yform-dataset-view-' . $id . ''; $dataset_real_id = 'yform-dataset-real-' . $id . ''; + $viewButton = ''; + if ('' === $value) { + $viewButton = ''; + } + $e['field'] = ' '; $e['functionButtons'] = ' - - '; + + + + ' . $viewButton; $e['before'] = '
'; $e['after'] = '
'; diff --git a/plugins/manager/ytemplates/bootstrap/value.be_manager_relation.tpl.php b/plugins/manager/ytemplates/bootstrap/value.be_manager_relation.tpl.php index 757d19a2b..1f561af56 100644 --- a/plugins/manager/ytemplates/bootstrap/value.be_manager_relation.tpl.php +++ b/plugins/manager/ytemplates/bootstrap/value.be_manager_relation.tpl.php @@ -71,6 +71,8 @@ $args['link'] = $link; $args['fieldName'] = $this->getRelationSourceTableName() . '.' . $this->getName(); $args['valueName'] = $valueName; + $_csrf_key = rex_yform_manager_table::get($this->relation['target_table'])->getCSRFKey(); + $args += rex_csrf_token::factory($_csrf_key)->getUrlParams(); $value = implode(',', $this->getValue()); echo \rex_var_yform_table_data::getSingleWidget($id, $name, $value, $args); } else { @@ -81,6 +83,8 @@ $args['fieldName'] = $this->getRelationSourceTableName() . '.' . $this->getName(); $args['size'] = $this->getRelationSize(); $args['attributes'] = $this->getAttributeArray([], ['required', 'readonly']); + $_csrf_key = rex_yform_manager_table::get($this->relation['target_table'])->getCSRFKey(); + $args += rex_csrf_token::factory($_csrf_key)->getUrlParams(); $value = implode(',', $this->getValue()); echo \rex_var_yform_table_data::getMultipleWidget($id, $name, $value, $args); }