Додана сторінка "історія служіння"
This commit is contained in:
3
web/lib/pages/territory_history/index.html
Normal file
3
web/lib/pages/territory_history/index.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<div class="page-territory_history">
|
||||
<div id="list"></div>
|
||||
</div>
|
||||
82
web/lib/pages/territory_history/script.js
Normal file
82
web/lib/pages/territory_history/script.js
Normal file
@@ -0,0 +1,82 @@
|
||||
const Territory_History = {
|
||||
list: [],
|
||||
|
||||
async init() {
|
||||
let html = await fetch('/lib/pages/territory_history/index.html').then((response) => response.text());
|
||||
app.innerHTML = html;
|
||||
|
||||
this.setHTML()
|
||||
},
|
||||
|
||||
async loadAPI(url) {
|
||||
const uuid = localStorage.getItem("uuid");
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": uuid
|
||||
}
|
||||
});
|
||||
return await response.json();
|
||||
},
|
||||
|
||||
async setHTML() {
|
||||
const block_list = document.getElementById('list');
|
||||
const url = `${CONFIG.api}history/apartments/list?limit=5000`;
|
||||
let list = this.list.length > 0 ? this.list : await this.loadAPI(url);
|
||||
|
||||
list.sort((a, b) => b.id - a.id);
|
||||
|
||||
let html = "";
|
||||
for (const element of list) {
|
||||
html += this.renderCard({ element });
|
||||
}
|
||||
|
||||
block_list.innerHTML = html;
|
||||
},
|
||||
|
||||
renderCard: ({ element }) => {
|
||||
console.log(element);
|
||||
|
||||
const labels = ["", "Відмова (Не цікавить)", "Не заходити (Груба відмова)", "Нема домофона", "Повторна відвідина", "Немає вдома", "Свідки Єгови"];
|
||||
const color_status = [
|
||||
["var(--ColorThemes2)", "var(--ColorThemes3)"],
|
||||
["#fbf1e0", "#ff8300"],
|
||||
["#fce3e2", "#ff0000"],
|
||||
["#d7ddec", "#2919bd"],
|
||||
["#d5e9dd", "#11a568"],
|
||||
["#d7ebfa", "#3fb4fc"],
|
||||
["#e8dbf5", "#b381eb"]
|
||||
];
|
||||
|
||||
const [bg, color] = color_status[element.status];
|
||||
|
||||
let description = element.description
|
||||
? `<div class="description"><p>${element.description}</p></div>`
|
||||
: ``;
|
||||
|
||||
return `
|
||||
<div class="card" style="background:${bg};color:${color};border:1px solid ${color}">
|
||||
<div class="info">
|
||||
<a href="/territory/card/house/${element.house_id}" class="address">
|
||||
<p title="${element.address.entrance}">${element.address.house.title} ${element.address.house.number}</p>
|
||||
</a>
|
||||
<div class="apartment">
|
||||
<p>кв. ${element.address.apartment}</p>
|
||||
</div>
|
||||
<div class="status">
|
||||
<p>${labels[element.status]}</p>
|
||||
</div>
|
||||
<a href="/sheeps/${element.sheep.id}" class="name">
|
||||
<p>${element.sheep.name}</p>
|
||||
</a>
|
||||
<div class="date">
|
||||
<p>${formattedDateTime(element.created_at)}</p>
|
||||
</div>
|
||||
</div>
|
||||
${description}
|
||||
</div>
|
||||
`;
|
||||
},
|
||||
}
|
||||
71
web/lib/pages/territory_history/style.css
Normal file
71
web/lib/pages/territory_history/style.css
Normal file
@@ -0,0 +1,71 @@
|
||||
.page-territory_history {
|
||||
width: calc(100% - 18px);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin: 20px 9px 0 9px;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.page-territory_history>#list {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.page-territory_history>#list>.card {
|
||||
display: flex;
|
||||
width: calc(100% - 2px);
|
||||
background: var(--ColorThemes1);
|
||||
border: 1px solid var(--ColorThemes2);
|
||||
border-radius: var(--border-radius);
|
||||
margin-bottom: 10px;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.page-territory_history>#list>.card>.info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.page-territory_history>#list>.card>.info>div {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.page-territory_history>#list>.card>.info>div>a,
|
||||
.page-territory_history>#list>.card>.info>div>p {
|
||||
font-size: var(--FontSize3);
|
||||
}
|
||||
|
||||
.page-territory_history>#list>.card>.info>.address {
|
||||
width: 20%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.page-territory_history>#list>.card>.info>.apartment {
|
||||
width: 60px;
|
||||
}
|
||||
|
||||
.page-territory_history>#list>.card>.info>.status {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.page-territory_history>#list>.card>.info>.name {
|
||||
width: 150px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.page-territory_history>#list>.card>.info>.date {
|
||||
width: 125px;
|
||||
}
|
||||
|
||||
.page-territory_history>#list>.card>.description {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin: 0 10px 10px 10px;
|
||||
background: var(--ColorThemes0);
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
Reference in New Issue
Block a user