AppML кейс - Категории
HTML страница
Это HTML ресурс:
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>Категории</title>
<link rel="stylesheet"
href="../w3css/4/w3.css">
<script src="2.0.3/appml.js"></script>
</head>
<body>
<div class="w3-container w3-content">
<h1>Категории</h1>
<div id="Form01" class="w3-container w3-light-grey
w3-padding-large w3-margin-bottom" appml-data="https://www.w3schools.com/appml/appml.php?model=model_categoriesform"
appml-controller="myFormController" style="display:none;">
<div
appml-include-html="inc_formcommands.html"></div>
<p>
<label>CategoryName:</label>
<input id="CategoryName" class="w3-input
w3-border">
</p>
<p>
<label>Description:</label>
<input id="Description" class="w3-input w3-border">
</p>
</div>
<div https://www.w3schools.com/appml/appml-data="appml.php?model=model_categorieslist">
<div appml-include-html="inc_listcommands_nofilter.html"></div>
<table
class="w3-table-all">
<tr>
<th></th>
<th>Category</th>
<th>Description</th>
</tr>
<tr appml-repeat="records">
<td style="cursor:pointer" onclick="appml('Form01').run({{CategoryID}})">✎</td>
<td>{{CategoryName}}</td>
<td>{{Description}}</td>
</tr>
</table>
</div>
</div>
<script>
function
myFormController($appml) {
if ($appml.message == "ready") {return -1;}
if ($appml.message == "loaded") {
document.getElementById("Form01").style.display = "";
}
}
</script>
</body>
</html>
PHP »
.NET »
Модели
Это модели, используемые в приложении:
Модель списка
{
"database" : {
"connection" : "localmysql",
"sql" : "SELECT *
FROM Categories"
}
}
Модель формы
{
"database" : {
"connection" : "localmysql",
"sql" : "SELECT *
FROM Categories",
"maintable" : "Categories",
"keyfield" :
"CategoryID"
},
"updateItems" : [
{"item" : "CategoryName"},
{"item" :
"Description"}
]
}