Skip to content

Commit

Permalink
style: reformat instrument detail init
Browse files Browse the repository at this point in the history
  • Loading branch information
kunfang98927 committed Jul 17, 2024
1 parent ca06214 commit f552546
Show file tree
Hide file tree
Showing 6 changed files with 323 additions and 300 deletions.
196 changes: 99 additions & 97 deletions web-app/django/VIM/apps/instruments/static/instruments/css/detail.css
Original file line number Diff line number Diff line change
@@ -1,97 +1,99 @@
.instrument-detail {
display: flex;
flex-wrap: nowrap;
align-items: center;
flex-direction: column;
padding: 50px;
}
.detail-header {
display: flex;
flex-direction: row;
justify-content: flex-start;
flex-wrap: wrap;
width: 100%;
}
.detail-header hr {
width: 100%;
}
.detail-body {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-evenly;
align-items: flex-start;
width: 100%;
}
.detail-image {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: flex-start;
}
.instrument-image {
max-width: 50%;
margin-right: 10px;
}
.detail-image-caption {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: flex-start;
}
.instrument-forms {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
width: 100%;
}
.name-form-item {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
}
.name-field {
width: 90%;
}
input.edit-field {
width: inherit;
}
th[scope="col"] {
width: 30%;
}
th[scope="row"] {
width: 20%;
}
.button-group {
display:flex;
flex-direction: row;
}
.edit-field, .btn.cancel, .btn.publish {
display: none;
}
.btn {
display: inline-block;
padding: 5px 10px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
border: none;
border-radius: 3px;
margin-right: 5px;
}
.btn.edit {
background-color: #ffc107;
}
.btn.cancel {
background-color: #dc3545;
}
.btn.publish {
background-color: #28a745;
}
.instrument-detail {
display: flex;
flex-wrap: nowrap;
align-items: center;
flex-direction: column;
padding: 50px;
}
.detail-header {
display: flex;
flex-direction: row;
justify-content: flex-start;
flex-wrap: wrap;
width: 100%;
}
.detail-header hr {
width: 100%;
}
.detail-body {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-evenly;
align-items: flex-start;
width: 100%;
}
.detail-image {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: flex-start;
}
.instrument-image {
max-width: 50%;
margin-right: 10px;
}
.detail-image-caption {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: flex-start;
}
.instrument-forms {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
width: 100%;
}
.name-form-item {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
}
.name-field {
width: 90%;
}
input.edit-field {
width: inherit;
}
th[scope='col'] {
width: 30%;
}
th[scope='row'] {
width: 20%;
}
.button-group {
display: flex;
flex-direction: row;
}
.edit-field,
.btn.cancel,
.btn.publish {
display: none;
}
.btn {
display: inline-block;
padding: 5px 10px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
border: none;
border-radius: 3px;
margin-right: 5px;
}
.btn.edit {
background-color: #ffc107;
}
.btn.cancel {
background-color: #dc3545;
}
.btn.publish {
background-color: #28a745;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@import url('https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css');

h2 {
color: #435334;
font-size: 30px;
font-weight: 800;
color: #435334;
font-size: 30px;
font-weight: 800;
}

h4 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@

document.addEventListener('DOMContentLoaded', function() {
const editButtons = document.querySelectorAll('.btn.edit');
const cancelButtons = document.querySelectorAll('.btn.cancel');
const publishButtons = document.querySelectorAll('.btn.publish');

editButtons.forEach(button => {
button.addEventListener('click', function() {
const parentTd = this.closest('td');
parentTd.querySelector('.view-field').style.display = 'none';
parentTd.querySelector('.edit-field').style.display = 'inline-block';
parentTd.querySelector('.btn.cancel').style.display = 'inline-block';
parentTd.querySelector('.btn.publish').style.display = 'inline-block';
this.style.display = 'none';
});
});

cancelButtons.forEach(button => {
button.addEventListener('click', function() {
const parentTd = this.closest('td');
parentTd.querySelector('.view-field').style.display = 'inline';
parentTd.querySelector('.edit-field').style.display = 'none';
parentTd.querySelector('.btn.edit').style.display = 'inline-block';
parentTd.querySelector('.btn.publish').style.display = 'none';
this.style.display = 'none';
});
});

publishButtons.forEach(button => {
button.addEventListener('click', function() {
const parentTd = this.closest('td');
const newValue = parentTd.querySelector('.edit-field').value;
// TODO: request to update the value on the server
parentTd.querySelector('.view-field').textContent = newValue;
parentTd.querySelector('.view-field').style.display = 'inline';
parentTd.querySelector('.edit-field').style.display = 'none';
parentTd.querySelector('.btn.edit').style.display = 'inline-block';
this.style.display = 'none';
parentTd.querySelector('.btn.cancel').style.display = 'none';
});
});
});
document.addEventListener('DOMContentLoaded', function () {
const editButtons = document.querySelectorAll('.btn.edit');
const cancelButtons = document.querySelectorAll('.btn.cancel');
const publishButtons = document.querySelectorAll('.btn.publish');

editButtons.forEach((button) => {
button.addEventListener('click', function () {
const parentTd = this.closest('td');
parentTd.querySelector('.view-field').style.display = 'none';
parentTd.querySelector('.edit-field').style.display = 'inline-block';
parentTd.querySelector('.btn.cancel').style.display = 'inline-block';
parentTd.querySelector('.btn.publish').style.display = 'inline-block';
this.style.display = 'none';
});
});

cancelButtons.forEach((button) => {
button.addEventListener('click', function () {
const parentTd = this.closest('td');
parentTd.querySelector('.view-field').style.display = 'inline';
parentTd.querySelector('.edit-field').style.display = 'none';
parentTd.querySelector('.btn.edit').style.display = 'inline-block';
parentTd.querySelector('.btn.publish').style.display = 'none';
this.style.display = 'none';
});
});

publishButtons.forEach((button) => {
button.addEventListener('click', function () {
const parentTd = this.closest('td');
const newValue = parentTd.querySelector('.edit-field').value;
// TODO: request to update the value on the server
parentTd.querySelector('.view-field').textContent = newValue;
parentTd.querySelector('.view-field').style.display = 'inline';
parentTd.querySelector('.edit-field').style.display = 'none';
parentTd.querySelector('.btn.edit').style.display = 'inline-block';
this.style.display = 'none';
parentTd.querySelector('.btn.cancel').style.display = 'none';
});
});
});
Loading

0 comments on commit f552546

Please sign in to comment.