Commit 62d7a0c7 authored by Van's avatar Van

🚧 #12256

parent e753f134
......@@ -86,7 +86,9 @@ userManageLabel=Users
commonUserLabel=Common User
visitorUserLabel=visitor
addUserLabel=Add User
addCategoryLabel=Add Category
updateUserLabel=Update User
updateCategoryLabel=Update Category
linkManagementLabel=Links
categoryListLabel=Category
pluginMgmtLabel=Plugins
......@@ -355,6 +357,7 @@ blogEmptyLabel=Blogging service is empty
blogArticleEmptyLabel=Please select articles
notAllowCommentLabel=Not allow comment!
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
mailInvalidLabel=Mail is invalid
urlInvalidLabel=URL is invalid
......
......@@ -86,7 +86,9 @@ userManageLabel=\u7528\u6237\u7BA1\u7406
commonUserLabel=\u4E00\u822C\u7528\u6237
visitorUserLabel=\u8BBF\u5BA2\u7528\u6237
addUserLabel=\u6DFB\u52A0\u7528\u6237
addCategoryLabel=\u6DFB\u52A0\u5206\u7C7B
updateUserLabel=\u66F4\u65B0\u7528\u6237
updateCategoryLabel=\u66F4\u65B0\u5206\u7C7B
linkManagementLabel=\u94FE\u63A5\u7BA1\u7406
categoryListLabel=\u5206\u7C7B\u7BA1\u7406
pluginMgmtLabel=\u63D2\u4EF6\u7BA1\u7406
......@@ -353,6 +355,7 @@ blogEmptyLabel=\u8BF7\u9009\u62E9\u535A\u5BA2\u670D\u52A1\uFF01
blogArticleEmptyLabel=\u8BF7\u9009\u62E9\u9700\u8981\u5BFC\u5165\u7684\u6587\u7AE0
notAllowCommentLabel=\u4E0D\u5141\u8BB8\u8BC4\u8BBA\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
mailInvalidLabel=\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01
urlInvalidLabel=\u94FE\u63A5\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01
......
<div>
<div id="userTable"></div>
<div id="userPagination" class="margin12 right"></div>
<div id="categoryTable"></div>
<div id="categoryPagination" class="margin12 right"></div>
</div>
<div class="clear"></div>
<table class="form" width="100%" cellpadding="0px" cellspacing="9px">
<thead>
<tr>
<th style="text-align: left" colspan="2">
${addUserLabel}
${addCategoryLabel}
</th>
</tr>
</thead>
<tbody>
<tr>
<th width="48px">
<label for="userName">${commentName1Label}</label>
<label for="categoryName">${linkTitle1Label}</label>
</th>
<td>
<input id="userName" type="text"/>
<input id="categoryName" type="text"/>
</td>
</tr>
<tr>
<th>
<label for="userEmail">${commentEmail1Label}</label>
<label for="categoryURI">URI:</label>
</th>
<td>
<input id="userEmail" type="text"/>
<input id="categoryURI" type="text"/>
</td>
</tr>
<tr>
<th>
<label for="userURL">${userURL1Label}</label>
<label for="categoryDesc">${linkDescription1Label}</label>
</th>
<td>
<input id="userURL" type="text"/>
<input id="categoryDesc" type="text"/>
</td>
</tr>
<tr>
<th>
<label for="userPassword">${userPassword1Label}</label>
<label for="categoryTags">${tags1Label}</label>
</th>
<td>
<input id="userPassword" type="password" autocomplete="new-password"/>
</td>
</tr>
<tr>
<th>
<label for="userAvatar">${userAvatar1Label}</label>
</th>
<td>
<input id="userAvatar" type="text"/>
<input id="categoryTags" type="text"/>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<button onclick="admin.userList.add();">${saveLabel}</button>
<button onclick="admin.categoryList.add();">${saveLabel}</button>
</td>
</tr>
</tbody>
</table>
<div id="userUpdate" class="none">
<div id="categoryUpdate" class="none">
<table class="form" width="100%" cellpadding="0px" cellspacing="9px">
<thead>
<tr>
<th style="text-align: left" colspan="2">
${updateUserLabel}
${updateCategoryLabel}
</th>
</tr>
</thead>
<tbody>
<tr>
<th width="48px">
<label for="userNameUpdate">${commentName1Label}</label>
</th>
<td>
<input id="userNameUpdate" type="text"/>
</td>
</tr>
<tr>
<th>
<label for="userEmailUpdate">${commentEmail1Label}</label>
<label for="categoryNameUpdate">${linkTitle1Label}</label>
</th>
<td>
<input id="userEmailUpdate" type="text"/>
<input id="categoryNameUpdate" type="text"/>
</td>
</tr>
<tr>
<th>
<label for="userURLUpdate">${userURL1Label}</label>
<label for="categoryURIUpdate">URI:</label>
</th>
<td>
<input id="userURLUpdate" type="text"/>
<input id="categoryURIUpdate" type="text"/>
</td>
</tr>
<tr>
<th>
<label for="userPasswordUpdate">${userPassword1Label}</label>
<label for="categoryDescUpdate">${linkDescription1Label}</label>
</th>
<td>
<input id="userPasswordUpdate" type="password"/>
<input id="categoryDescUpdate" type="text"/>
</td>
</tr>
<tr>
<th>
<label for="userAvatarUpdate">${userAvatar1Label}</label>
<label for="categoryTagsUpdate">${tags1Label}</label>
</th>
<td>
<input id="userAvatarUpdate" type="text"/>
<input id="categoryTagsUpdate" type="text"/>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<button onclick="admin.userList.update();">${updateLabel}</button>
<button onclick="admin.categoryList.update();">${updateLabel}</button>
</td>
</tr>
</tbody>
......
......@@ -76,7 +76,7 @@
</div>
</li>
<li>
<div id="tabs_category">
<div id="tabs_category-list">
<a href="#tools/category-list">${categoryListLabel}</a>
</div>
</li>
......
......@@ -121,6 +121,7 @@
"userLabel": "${userLabel}",
"changeRoleLabel": "${changeRoleLabel}",
"visitorUserLabel": "${visitorUserLabel}",
"categoryTooLongLabel": "${categoryTooLongLabel}",
"autoSaveLabel": "${autoSaveLabel}"
};
......
......@@ -23,10 +23,10 @@ var Admin = function () {
this.register = {};
// 工具栏下的工具
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',
'user-list', 'plugin-list', 'others'];
'user-list', 'plugin-list', 'others', 'category-list'];
};
$.extend(Admin.prototype, {
......
......@@ -37,20 +37,24 @@ admin.categoryList = {
*/
init: function(page) {
this.tablePagination.buildTable([{
text: "",
index: "linkOrder",
width: 60
}, {
style: "padding-left: 12px;",
text: Label.commentNameLabel,
index: "categoryName",
text: Label.linkTitleLabel,
index: "categoryTitle",
width: 230
}, {
style: "padding-left: 12px;",
text: Label.commentEmailLabel,
index: "categoryEmail",
minWidth: 180
text: 'URI',
index: "categoryURI",
width: 230
}, {
style: "padding-left: 12px;",
text: Label.roleLabel,
index: "isAdmin",
width: 120
text: Label.linkDescriptionLabel,
index: "categoryDesc",
minWidth: 180
}]);
this.tablePagination.initPagination();
......@@ -84,38 +88,45 @@ admin.categoryList = {
return;
}
var categorys = result.categorys;
var categories = result.categories;
var categoryData = [];
admin.categoryList.pageInfo.currentCount = categorys.length;
admin.categoryList.pageInfo.currentCount = categories.length;
admin.categoryList.pageInfo.pageCount = result.pagination.paginationPageCount;
if (categorys.length < 1) {
if (categories.length < 1) {
$("#tipMsg").text("No category " + Label.reportIssueLabel);
$("#loadMsg").text("");
return;
}
for (var i = 0; i < categorys.length; i++) {
for (var i = 0; i < categories.length; i++) {
categoryData[i] = {};
categoryData[i].categoryName = categorys[i].categoryName;
categoryData[i].categoryEmail = categorys[i].categoryEmail;
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 {
categoryData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.categoryList.get('" +
categorys[i].oId + "', '" + categorys[i].categoryRole + "')\">" + Label.updateLabel + "</a>\
<a href='javascript:void(0)' onclick=\"admin.categoryList.del('" + categorys[i].oId + "', '" + categorys[i].categoryName + "')\">" + Label.removeLabel + "</a> " +
"<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;
if (i === 0) {
if (categories.length === 1) {
categoryData[i].linkOrder = "";
} else {
categoryData[i].linkOrder = '<div class="table-center" style="width:14px">\
<span onclick="admin.categoryList.changeOrder(' + categories[i].oId + ', ' + i + ', \'down\');" class="table-downIcon"></span>\
</div>';
}
} 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);
$("#loadMsg").text("");
......@@ -124,7 +135,7 @@ admin.categoryList = {
});
},
/*
* 添加用户
* 添加分类
*/
add: function() {
if (this.validate()) {
......@@ -133,10 +144,9 @@ admin.categoryList = {
var requestJSONObject = {
"categoryName": $("#categoryName").val(),
"categoryEmail": $("#categoryEmail").val(),
"categoryURL": $("#categoryURL").val(),
"categoryPassword": $("#categoryPassword").val(),
"categoryAvatar": $("#categoryAvatar").val()
"categoryTags": $("#categoryTags").val(),
"categoryURI": $("#categoryURI").val(),
"categoryDesc": $("#categoryDesc").val()
};
$.ajax({
......@@ -152,10 +162,9 @@ admin.categoryList = {
}
$("#categoryName").val("");
$("#categoryEmail").val("");
$("#categoryURL").val("");
$("#categoryPassword").val("");
$("#categoryAvatar").val("");
$("#categoryTags").val("");
$("#categoryURI").val("");
$("#categoryDesc").val("");
if (admin.categoryList.pageInfo.currentCount === Label.PAGE_SIZE &&
admin.categoryList.pageInfo.currentPage === admin.categoryList.pageInfo.pageCount) {
admin.categoryList.pageInfo.pageCount++;
......@@ -332,22 +341,43 @@ admin.categoryList = {
status = "";
}
var categoryName = $("#categoryName" + status).val().replace(/(^\s*)|(\s*$)/g, "");
if (2 > categoryName.length || categoryName.length > 20) {
$("#tipMsg").text(Label.nameTooLongLabel);
if (2 > categoryName.length || categoryName.length > 32) {
$("#tipMsg").text(Label.categoryTooLongLabel);
$("#categoryName" + status).focus();
} else if ($("#categoryEmail" + status).val().replace(/\s/g, "") === "") {
$("#tipMsg").text(Label.mailCannotEmptyLabel);
$("#categoryEmail" + 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 if ($.trim($("#categoryTags" + status).val()) === "") {
$("#tipMsg").text(Label.tagsEmptyLabel);
$("#categoryTags" + status).focus();
} else {
return true;
}
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