Commit 62d7a0c7 authored by Van's avatar Van

🚧 #12256

parent e753f134
...@@ -86,7 +86,9 @@ userManageLabel=Users ...@@ -86,7 +86,9 @@ userManageLabel=Users
commonUserLabel=Common User commonUserLabel=Common User
visitorUserLabel=visitor visitorUserLabel=visitor
addUserLabel=Add User addUserLabel=Add User
addCategoryLabel=Add Category
updateUserLabel=Update User updateUserLabel=Update User
updateCategoryLabel=Update Category
linkManagementLabel=Links linkManagementLabel=Links
categoryListLabel=Category categoryListLabel=Category
pluginMgmtLabel=Plugins pluginMgmtLabel=Plugins
...@@ -355,6 +357,7 @@ blogEmptyLabel=Blogging service is empty ...@@ -355,6 +357,7 @@ blogEmptyLabel=Blogging service is empty
blogArticleEmptyLabel=Please select articles blogArticleEmptyLabel=Please select articles
notAllowCommentLabel=Not allow comment! notAllowCommentLabel=Not allow comment!
nameTooLongLabel=Sorry, your username must be between 2 and 20 characters long. nameTooLongLabel=Sorry, your username must be between 2 and 20 characters long.
categoryTooLongLabel=Sorry, category name must be between 2 and 32 characters long.
mailCannotEmptyLabel=Mail is empty mailCannotEmptyLabel=Mail is empty
mailInvalidLabel=Mail is invalid mailInvalidLabel=Mail is invalid
urlInvalidLabel=URL is invalid urlInvalidLabel=URL is invalid
......
...@@ -86,7 +86,9 @@ userManageLabel=\u7528\u6237\u7BA1\u7406 ...@@ -86,7 +86,9 @@ userManageLabel=\u7528\u6237\u7BA1\u7406
commonUserLabel=\u4E00\u822C\u7528\u6237 commonUserLabel=\u4E00\u822C\u7528\u6237
visitorUserLabel=\u8BBF\u5BA2\u7528\u6237 visitorUserLabel=\u8BBF\u5BA2\u7528\u6237
addUserLabel=\u6DFB\u52A0\u7528\u6237 addUserLabel=\u6DFB\u52A0\u7528\u6237
addCategoryLabel=\u6DFB\u52A0\u5206\u7C7B
updateUserLabel=\u66F4\u65B0\u7528\u6237 updateUserLabel=\u66F4\u65B0\u7528\u6237
updateCategoryLabel=\u66F4\u65B0\u5206\u7C7B
linkManagementLabel=\u94FE\u63A5\u7BA1\u7406 linkManagementLabel=\u94FE\u63A5\u7BA1\u7406
categoryListLabel=\u5206\u7C7B\u7BA1\u7406 categoryListLabel=\u5206\u7C7B\u7BA1\u7406
pluginMgmtLabel=\u63D2\u4EF6\u7BA1\u7406 pluginMgmtLabel=\u63D2\u4EF6\u7BA1\u7406
...@@ -353,6 +355,7 @@ blogEmptyLabel=\u8BF7\u9009\u62E9\u535A\u5BA2\u670D\u52A1\uFF01 ...@@ -353,6 +355,7 @@ blogEmptyLabel=\u8BF7\u9009\u62E9\u535A\u5BA2\u670D\u52A1\uFF01
blogArticleEmptyLabel=\u8BF7\u9009\u62E9\u9700\u8981\u5BFC\u5165\u7684\u6587\u7AE0 blogArticleEmptyLabel=\u8BF7\u9009\u62E9\u9700\u8981\u5BFC\u5165\u7684\u6587\u7AE0
notAllowCommentLabel=\u4E0D\u5141\u8BB8\u8BC4\u8BBA\uFF01 notAllowCommentLabel=\u4E0D\u5141\u8BB8\u8BC4\u8BBA\uFF01
nameTooLongLabel=\u59D3\u540D\u53EA\u80FD\u4E3A 2 \u5230 20 \u4E2A\u5B57\u7B26\uFF01 nameTooLongLabel=\u59D3\u540D\u53EA\u80FD\u4E3A 2 \u5230 20 \u4E2A\u5B57\u7B26\uFF01
categoryTooLongLabel=\u5206\u7C7B\u540D\u79F0\u53EA\u80FD\u4E3A 2 \u5230 32 \u4E2A\u5B57\u7B26\uFF01
mailCannotEmptyLabel=\u90AE\u7BB1\u4E0D\u80FD\u4E3A\u7A7A\uFF01 mailCannotEmptyLabel=\u90AE\u7BB1\u4E0D\u80FD\u4E3A\u7A7A\uFF01
mailInvalidLabel=\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01 mailInvalidLabel=\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01
urlInvalidLabel=\u94FE\u63A5\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01 urlInvalidLabel=\u94FE\u63A5\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01
......
<div> <div>
<div id="userTable"></div> <div id="categoryTable"></div>
<div id="userPagination" class="margin12 right"></div> <div id="categoryPagination" class="margin12 right"></div>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
<table class="form" width="100%" cellpadding="0px" cellspacing="9px"> <table class="form" width="100%" cellpadding="0px" cellspacing="9px">
<thead> <thead>
<tr> <tr>
<th style="text-align: left" colspan="2"> <th style="text-align: left" colspan="2">
${addUserLabel} ${addCategoryLabel}
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<th width="48px"> <th width="48px">
<label for="userName">${commentName1Label}</label> <label for="categoryName">${linkTitle1Label}</label>
</th> </th>
<td> <td>
<input id="userName" type="text"/> <input id="categoryName" type="text"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th> <th>
<label for="userEmail">${commentEmail1Label}</label> <label for="categoryURI">URI:</label>
</th> </th>
<td> <td>
<input id="userEmail" type="text"/> <input id="categoryURI" type="text"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th> <th>
<label for="userURL">${userURL1Label}</label> <label for="categoryDesc">${linkDescription1Label}</label>
</th> </th>
<td> <td>
<input id="userURL" type="text"/> <input id="categoryDesc" type="text"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th> <th>
<label for="userPassword">${userPassword1Label}</label> <label for="categoryTags">${tags1Label}</label>
</th> </th>
<td> <td>
<input id="userPassword" type="password" autocomplete="new-password"/> <input id="categoryTags" type="text"/>
</td>
</tr>
<tr>
<th>
<label for="userAvatar">${userAvatar1Label}</label>
</th>
<td>
<input id="userAvatar" type="text"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2" align="right"> <td colspan="2" align="right">
<button onclick="admin.userList.add();">${saveLabel}</button> <button onclick="admin.categoryList.add();">${saveLabel}</button>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div id="userUpdate" class="none"> <div id="categoryUpdate" class="none">
<table class="form" width="100%" cellpadding="0px" cellspacing="9px"> <table class="form" width="100%" cellpadding="0px" cellspacing="9px">
<thead> <thead>
<tr> <tr>
<th style="text-align: left" colspan="2"> <th style="text-align: left" colspan="2">
${updateUserLabel} ${updateCategoryLabel}
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<th width="48px"> <th width="48px">
<label for="userNameUpdate">${commentName1Label}</label> <label for="categoryNameUpdate">${linkTitle1Label}</label>
</th>
<td>
<input id="userNameUpdate" type="text"/>
</td>
</tr>
<tr>
<th>
<label for="userEmailUpdate">${commentEmail1Label}</label>
</th> </th>
<td> <td>
<input id="userEmailUpdate" type="text"/> <input id="categoryNameUpdate" type="text"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th> <th>
<label for="userURLUpdate">${userURL1Label}</label> <label for="categoryURIUpdate">URI:</label>
</th> </th>
<td> <td>
<input id="userURLUpdate" type="text"/> <input id="categoryURIUpdate" type="text"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th> <th>
<label for="userPasswordUpdate">${userPassword1Label}</label> <label for="categoryDescUpdate">${linkDescription1Label}</label>
</th> </th>
<td> <td>
<input id="userPasswordUpdate" type="password"/> <input id="categoryDescUpdate" type="text"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<th> <th>
<label for="userAvatarUpdate">${userAvatar1Label}</label> <label for="categoryTagsUpdate">${tags1Label}</label>
</th> </th>
<td> <td>
<input id="userAvatarUpdate" type="text"/> <input id="categoryTagsUpdate" type="text"/>
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2" align="right"> <td colspan="2" align="right">
<button onclick="admin.userList.update();">${updateLabel}</button> <button onclick="admin.categoryList.update();">${updateLabel}</button>
</td> </td>
</tr> </tr>
</tbody> </tbody>
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
</div> </div>
</li> </li>
<li> <li>
<div id="tabs_category"> <div id="tabs_category-list">
<a href="#tools/category-list">${categoryListLabel}</a> <a href="#tools/category-list">${categoryListLabel}</a>
</div> </div>
</li> </li>
......
...@@ -121,6 +121,7 @@ ...@@ -121,6 +121,7 @@
"userLabel": "${userLabel}", "userLabel": "${userLabel}",
"changeRoleLabel": "${changeRoleLabel}", "changeRoleLabel": "${changeRoleLabel}",
"visitorUserLabel": "${visitorUserLabel}", "visitorUserLabel": "${visitorUserLabel}",
"categoryTooLongLabel": "${categoryTooLongLabel}",
"autoSaveLabel": "${autoSaveLabel}" "autoSaveLabel": "${autoSaveLabel}"
}; };
......
...@@ -23,10 +23,10 @@ var Admin = function () { ...@@ -23,10 +23,10 @@ var Admin = function () {
this.register = {}; this.register = {};
// 工具栏下的工具 // 工具栏下的工具
this.tools = ['#page-list', '#file-list', '#link-list', '#preference', this.tools = ['#page-list', '#file-list', '#link-list', '#preference',
'#user-list', '#plugin-list', '#others']; '#user-list', '#plugin-list', '#others', '#category-list'];
// 多用户时,一般用户不能使用的功能 // 多用户时,一般用户不能使用的功能
this.adTools = ['link-list', 'preference', 'file-list', 'page-list', this.adTools = ['link-list', 'preference', 'file-list', 'page-list',
'user-list', 'plugin-list', 'others']; 'user-list', 'plugin-list', 'others', 'category-list'];
}; };
$.extend(Admin.prototype, { $.extend(Admin.prototype, {
......
...@@ -37,20 +37,24 @@ admin.categoryList = { ...@@ -37,20 +37,24 @@ admin.categoryList = {
*/ */
init: function(page) { init: function(page) {
this.tablePagination.buildTable([{ this.tablePagination.buildTable([{
text: "",
index: "linkOrder",
width: 60
}, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.commentNameLabel, text: Label.linkTitleLabel,
index: "categoryName", index: "categoryTitle",
width: 230 width: 230
}, { }, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.commentEmailLabel, text: 'URI',
index: "categoryEmail", index: "categoryURI",
minWidth: 180 width: 230
}, { }, {
style: "padding-left: 12px;", style: "padding-left: 12px;",
text: Label.roleLabel, text: Label.linkDescriptionLabel,
index: "isAdmin", index: "categoryDesc",
width: 120 minWidth: 180
}]); }]);
this.tablePagination.initPagination(); this.tablePagination.initPagination();
...@@ -84,38 +88,45 @@ admin.categoryList = { ...@@ -84,38 +88,45 @@ admin.categoryList = {
return; return;
} }
var categorys = result.categorys; var categories = result.categories;
var categoryData = []; var categoryData = [];
admin.categoryList.pageInfo.currentCount = categorys.length; admin.categoryList.pageInfo.currentCount = categories.length;
admin.categoryList.pageInfo.pageCount = result.pagination.paginationPageCount; admin.categoryList.pageInfo.pageCount = result.pagination.paginationPageCount;
if (categorys.length < 1) { if (categories.length < 1) {
$("#tipMsg").text("No category " + Label.reportIssueLabel); $("#tipMsg").text("No category " + Label.reportIssueLabel);
$("#loadMsg").text(""); $("#loadMsg").text("");
return; return;
} }
for (var i = 0; i < categorys.length; i++) { for (var i = 0; i < categories.length; i++) {
categoryData[i] = {}; categoryData[i] = {};
categoryData[i].categoryName = categorys[i].categoryName; if (i === 0) {
categoryData[i].categoryEmail = categorys[i].categoryEmail; if (categories.length === 1) {
categoryData[i].linkOrder = "";
if ("adminRole" === categorys[i].categoryRole) {
categoryData[i].isAdmin = "&nbsp;" + Label.administratorLabel;
categoryData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.categoryList.get('" +
categorys[i].oId + "', '" + categorys[i].categoryRole + "')\">" + Label.updateLabel + "</a>";
} else { } else {
categoryData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.categoryList.get('" + categoryData[i].linkOrder = '<div class="table-center" style="width:14px">\
categorys[i].oId + "', '" + categorys[i].categoryRole + "')\">" + Label.updateLabel + "</a>\ <span onclick="admin.categoryList.changeOrder(' + categories[i].oId + ', ' + i + ', \'down\');" class="table-downIcon"></span>\
<a href='javascript:void(0)' onclick=\"admin.categoryList.del('" + categorys[i].oId + "', '" + categorys[i].categoryName + "')\">" + Label.removeLabel + "</a> " + </div>';
"<a href='javascript:void(0)' onclick=\"admin.categoryList.changeRole('" + categorys[i].oId + "')\">" + Label.changeRoleLabel + "</a>";
if ("defaultRole" === categorys[i].categoryRole) {
categoryData[i].isAdmin = Label.commonUserLabel;
}
else {
categoryData[i].isAdmin = Label.visitorUserLabel;
} }
} else if (i === categories.length - 1) {
categoryData[i].linkOrder = '<div class="table-center" style="width:14px">\
<span onclick="admin.categoryList.changeOrder(' + categories[i].oId + ', ' + i + ', \'up\');" class="table-upIcon"></span>\
</div>';
} else {
categoryData[i].linkOrder = '<div class="table-center" style="width:38px">\
<span onclick="admin.categoryList.changeOrder(' + categories[i].oId + ', ' + i + ', \'up\');" class="table-upIcon"></span>\
<span onclick="admin.categoryList.changeOrder(' + categories[i].oId + ', ' + i + ', \'down\');" class="table-downIcon"></span>\
</div>';
} }
categoryData[i].categoryTitle = categories[i].categoryTitle;
categoryData[i].categoryURI = categories[i].categoryURI;
categoryData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.categoryList.get('" +
categories[i].oId + "')\">" + Label.updateLabel + "</a>\
<a href='javascript:void(0)' onclick=\"admin.categoryList.del('" + categories[i].oId + "', '" +
categories[i].categoryName + "')\">" + Label.removeLabel + "</a> ";
that.tablePagination.updateTablePagination(categoryData, pageNum, result.pagination); that.tablePagination.updateTablePagination(categoryData, pageNum, result.pagination);
$("#loadMsg").text(""); $("#loadMsg").text("");
...@@ -124,7 +135,7 @@ admin.categoryList = { ...@@ -124,7 +135,7 @@ admin.categoryList = {
}); });
}, },
/* /*
* 添加用户 * 添加分类
*/ */
add: function() { add: function() {
if (this.validate()) { if (this.validate()) {
...@@ -133,10 +144,9 @@ admin.categoryList = { ...@@ -133,10 +144,9 @@ admin.categoryList = {
var requestJSONObject = { var requestJSONObject = {
"categoryName": $("#categoryName").val(), "categoryName": $("#categoryName").val(),
"categoryEmail": $("#categoryEmail").val(), "categoryTags": $("#categoryTags").val(),
"categoryURL": $("#categoryURL").val(), "categoryURI": $("#categoryURI").val(),
"categoryPassword": $("#categoryPassword").val(), "categoryDesc": $("#categoryDesc").val()
"categoryAvatar": $("#categoryAvatar").val()
}; };
$.ajax({ $.ajax({
...@@ -152,10 +162,9 @@ admin.categoryList = { ...@@ -152,10 +162,9 @@ admin.categoryList = {
} }
$("#categoryName").val(""); $("#categoryName").val("");
$("#categoryEmail").val(""); $("#categoryTags").val("");
$("#categoryURL").val(""); $("#categoryURI").val("");
$("#categoryPassword").val(""); $("#categoryDesc").val("");
$("#categoryAvatar").val("");
if (admin.categoryList.pageInfo.currentCount === Label.PAGE_SIZE && if (admin.categoryList.pageInfo.currentCount === Label.PAGE_SIZE &&
admin.categoryList.pageInfo.currentPage === admin.categoryList.pageInfo.pageCount) { admin.categoryList.pageInfo.currentPage === admin.categoryList.pageInfo.pageCount) {
admin.categoryList.pageInfo.pageCount++; admin.categoryList.pageInfo.pageCount++;
...@@ -332,22 +341,43 @@ admin.categoryList = { ...@@ -332,22 +341,43 @@ admin.categoryList = {
status = ""; status = "";
} }
var categoryName = $("#categoryName" + status).val().replace(/(^\s*)|(\s*$)/g, ""); var categoryName = $("#categoryName" + status).val().replace(/(^\s*)|(\s*$)/g, "");
if (2 > categoryName.length || categoryName.length > 20) { if (2 > categoryName.length || categoryName.length > 32) {
$("#tipMsg").text(Label.nameTooLongLabel); $("#tipMsg").text(Label.categoryTooLongLabel);
$("#categoryName" + status).focus(); $("#categoryName" + status).focus();
} else if ($("#categoryEmail" + status).val().replace(/\s/g, "") === "") { } else if ($.trim($("#categoryTags" + status).val()) === "") {
$("#tipMsg").text(Label.mailCannotEmptyLabel); $("#tipMsg").text(Label.tagsEmptyLabel);
$("#categoryEmail" + status).focus(); $("#categoryTags" + status).focus();
} else if (!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($("#categoryEmail" + status).val())) {
$("#tipMsg").text(Label.mailInvalidLabel);
$("#categoryEmail" + status).focus();
} else if ($("#categoryPassword" + status).val() === "") {
$("#tipMsg").text(Label.passwordEmptyLabel);
$("#categoryPassword" + status).focus();
} else { } else {
return true; return true;
} }
return false; return false;
},
/*
* 调换顺序
*/
changeOrder: function (id, order, status) {
$("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
var requestJSONObject = {
"oId": id.toString(),
"direction": status
};
$.ajax({
url: latkeConfig.servePath + "/console/link/category/",
type: "PUT",
cache: false,
data: JSON.stringify(requestJSONObject),
success: function(result, textStatus){
$("#tipMsg").text(result.msg);
// Refershes the link list
admin.categoryList.getList(admin.categoryList.pageInfo.currentPage);
$("#loadMsg").text("");
}
});
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment