diff --git a/frontend/controllers/CabinetController.php b/frontend/controllers/CabinetController.php index 994ef88..22b446d 100755 --- a/frontend/controllers/CabinetController.php +++ b/frontend/controllers/CabinetController.php @@ -269,6 +269,40 @@ ]; } } + + public function actionUpdateRole() + { + $request = \Yii::$app->request; + $response = \Yii::$app->response; + $response->format = $response::FORMAT_JSON; + + $role = CreativeRole::findOne($request->get('id')); + + if ($role->load($request->post()) && $role->save()) { + return [ + 'success' => true, + 'message' => 'Данные успешно сохранены', + ]; + } else { + return [ + 'error' => true, + 'message' => 'Ошибка сохранения данных', + ]; + } + } + + public function actionGetRoleForm() + { + $request = \Yii::$app->request; + $response = \Yii::$app->response; + $response->format = $response::FORMAT_JSON; + + $model = CreativeRole::findOne($request->post('id')); + + return [ + 'answer' => $this->renderPartial('_update_form', ['model' => $model]) + ]; + } public function actionDeleteRole() { diff --git a/frontend/views/cabinet/_update_form.php b/frontend/views/cabinet/_update_form.php new file mode 100644 index 0000000..060cb31 --- /dev/null +++ b/frontend/views/cabinet/_update_form.php @@ -0,0 +1,68 @@ + + + diff --git a/frontend/views/cabinet/index.php b/frontend/views/cabinet/index.php index d069e53..cdbbb35 100755 --- a/frontend/views/cabinet/index.php +++ b/frontend/views/cabinet/index.php @@ -68,7 +68,7 @@ ?> - title ?> + title, ['sales', 'id' => $row->id])?> registration_date ?> genre ?> author_role ?> diff --git a/frontend/views/cabinet/sales.php b/frontend/views/cabinet/sales.php index 5a9d9b0..03718cb 100755 --- a/frontend/views/cabinet/sales.php +++ b/frontend/views/cabinet/sales.php @@ -179,7 +179,7 @@ code ?> iri ?> society ?> - + + + + + + \ No newline at end of file diff --git a/frontend/web/css/cabinet-style.css b/frontend/web/css/cabinet-style.css index 4981ab9..c040532 100755 --- a/frontend/web/css/cabinet-style.css +++ b/frontend/web/css/cabinet-style.css @@ -748,7 +748,9 @@ ul.list-cab li.active-li ul li.active-li-drop span.act_bg { /* Add modal */ -#add-composition-modal .forms-cabinet, #add-role-modal .forms-cabinet { +#add-composition-modal .forms-cabinet, +#add-role-modal .forms-cabinet, +#update-role-modal .forms-cabinet { width: 100%; margin: 0; max-width: 1000px; diff --git a/frontend/web/js/script.js b/frontend/web/js/script.js index d1a7571..cf0700c 100755 --- a/frontend/web/js/script.js +++ b/frontend/web/js/script.js @@ -291,6 +291,23 @@ $(document).ready(function(){ return false; }); + $(document).on('submit', '#update-role-form', function() { + $.post($(this).attr('action'), $(this).serialize(), function(data) { + var type; + if(data.error) { + type = 'danger'; + } else { + type = 'success'; + } + $('#update-role-modal').modal('hide'); + showStatus(data.message, type); + $.pjax.reload('#roles-table'); + $('#update-role-modal').html(''); + }); + + return false; + }); + $(document).on('click', '.delete-role', function(e) { e.preventDefault(); confirm('Удалить роль?'); @@ -308,6 +325,16 @@ $(document).ready(function(){ }); }); + $(document).on('click', '.update-role', function(e) { + e.preventDefault(); + $.post('get-role-form', { + id:$(this).attr('data-id') + }, function(data) { + $('#update-role-modal').html(data.answer); + $('#update-role-modal').modal('show'); + }); + }); + $(document).on('click', '.remove-int-prop', function(e) { e.preventDefault(); confirm('Удалить элемент?'); -- libgit2 0.21.4