diff --git a/src/app.html b/src/app.html index f95174c..a528d43 100644 --- a/src/app.html +++ b/src/app.html @@ -388,29 +388,28 @@ diff --git a/src/components/api-table-view-form/ApiTableViewForm.css b/src/components/api-table-view-form/ApiTableViewForm.css index 986f690..50e5e9d 100644 --- a/src/components/api-table-view-form/ApiTableViewForm.css +++ b/src/components/api-table-view-form/ApiTableViewForm.css @@ -2,17 +2,43 @@ height: 200px; } .Api__view-controls { - position: absolute; - right: 40px; - top: 10px; - font-size: 20px; - z-index: 10000; + position: sticky; + bottom: 0; + width: 100%; + font-size: 1em; + display: flex; + flex-direction: row; + justify-content: space-around; + background-color: white; + min-height: 50px; } .Button__delete { - background: none; - border: none; + width: 100%; +} +.Button__delete-text { + margin: 10px; } .Button__edit { - background: none; - border: none; + width: 100%; +} +.Button__edit-text { + margin: 10px; +} +.Button__cancel { + width: 100%; +} +.Button__cancel-text { + margin: 10px; +} + +@media (max-width: 600px) { + .Button__delete-text { + display: none; + } + .Button__edit-text { + display: none; + } + .Button__cancel-text { + display: none; + } } \ No newline at end of file diff --git a/src/components/api-table-view-form/ApiTableViewForm.js b/src/components/api-table-view-form/ApiTableViewForm.js index 1b52c93..73728d9 100644 --- a/src/components/api-table-view-form/ApiTableViewForm.js +++ b/src/components/api-table-view-form/ApiTableViewForm.js @@ -13,6 +13,7 @@ class ApiTableViewForm extends Component { content: this.mainNode }); this.key = null; + this.isEdit = false; this.title = this.mainNode.querySelector('.h2'); this.form = this.mainNode.querySelector('form'); @@ -22,10 +23,23 @@ class ApiTableViewForm extends Component { this.deleteApi(this.key); } }); + this.editBtn = this.mainNode.querySelector('.Button__edit'); + this.addEventListener(this.editBtn, 'click', () => { + this.editApi(); + }); + this.editIcon = this.mainNode.querySelector('.Edit__icon'); + this.editBtnText = this.mainNode.querySelector('.Button__edit-text'); + this.editBtnText.textContent = 'Редактировать'; + + this.deleteBtnText = this.mainNode.querySelector('.Button__delete-text'); + this.deleteBtnText.textContent = 'Удалить'; + + this.cancelBtnText = this.mainNode.querySelector('.Button__cancel-text'); + this.cancelBtnText.textContent = 'Отменить'; this.title.textContent = 'Информация о хранилище'; - const inputs = [ + this.inputs = [ this.keyInput = this.createComponent(FormControl, this.form, { id: 'api-key-input', label: 'Название хранилища' @@ -50,7 +64,7 @@ class ApiTableViewForm extends Component { }), ]; - inputs.forEach((input) => { + this.inputs.forEach((input) => { input.disabled(true); }); } @@ -76,5 +90,23 @@ class ApiTableViewForm extends Component { this.next('deleteApi'); this.sidebar.hide(); } + + editApi () { + if (!this.isEdit) { + this.inputs.forEach((input) => { + input.disabled(false); + }); + this.editBtnText.textContent = 'Сохранить'; + this.editIcon.className = 'fas fa-check Edit__icon'; + this.isEdit = true; + } else { + this.inputs.forEach((input) => { + input.disabled(true); + }); + this.editBtnText.textContent = 'Редактировать'; + this.editIcon.className = 'fas fa-pencil-alt Edit__icon'; + this.isEdit = false; + } + } } export default ApiTableViewForm;