Skip to content

Commit

Permalink
允许撤销删除组件
Browse files Browse the repository at this point in the history
  • Loading branch information
SeriaWei committed Dec 28, 2023
1 parent af58b9d commit 96a62b5
Show file tree
Hide file tree
Showing 20 changed files with 150 additions and 86 deletions.
7 changes: 7 additions & 0 deletions Database/Update/3.9.3/MsSql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if not exists(select 1 from DataDictionary where DicName=N'WidgetStatus')
begin
insert into DataDictionary(DicName,Title,DicValue,[Order],Pid,IsSystem,[Status])
select N'WidgetStatus',N'Visible',1,1,0,1,1 union all
select N'WidgetStatus',N'Hidden',2,2,0,1,1 union all
select N'WidgetStatus',N'Deleted',3,3,0,1,1
end
5 changes: 5 additions & 0 deletions Database/Update/3.9.3/MySql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
delete from `DataDictionary` where `DicName`='WidgetStatus';
insert into `DataDictionary`(`DicName`,`Title`,`DicValue`,`Order`,`Pid`,`IsSystem`,`Status`)
select 'WidgetStatus','Visible',1,1,0,1,1 union all
select 'WidgetStatus','Hidden',2,2,0,1,1 union all
select 'WidgetStatus','Deleted',3,3,0,1,1
5 changes: 5 additions & 0 deletions Database/Update/3.9.3/Sqlite.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
delete from DataDictionary where DicName='WidgetStatus';
insert into DataDictionary(DicName,Title,DicValue,[Order],Pid,IsSystem,[Status])
select 'WidgetStatus','Visible',1,1,0,1,1 union all
select 'WidgetStatus','Hidden',2,2,0,1,1 union all
select 'WidgetStatus','Deleted',3,3,0,1,1
Binary file added Database/Update/3.9.3/package.zip
Binary file not shown.
4 changes: 4 additions & 0 deletions Database/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
{
"Version": "3.9",
"Resolved": "Update/3.9/package.zip"
},
{
"Version": "3.9.3",
"Resolved": "Update/3.9.3/package.zip"
}
]
}
2 changes: 1 addition & 1 deletion src/EasyFrameWork/ViewPort/Descriptor/SelectDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public SourceType SourceType
{
Dictionary<string, string> data = new Dictionary<string, string>();
IDataDictionaryService dicService = ServiceLocator.GetService<IDataDictionaryService>();
var dicts = dicService.Get(m => m.DicName == this.SourceKey);
var dicts = dicService.Get(m => m.DicName == this.SourceKey).OrderBy(m => m.Order);
foreach (DataDictionaryEntity item in dicts)
{
data[item.DicValue] = item.Title;
Expand Down
3 changes: 2 additions & 1 deletion src/ZKEACMS.WebHost/Locale/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1541,4 +1541,5 @@ View Video Category: 查看视频类别
Manage Video Category: 管理视频类别
Video(Embed): 视频(嵌入)
Name already exists: 名称已存在
Please upload video or input video code: 请上传视频或者输入视频代码
Please upload video or input video code: 请上传视频或者输入视频代码
Deleted: 已删除
3 changes: 2 additions & 1 deletion src/ZKEACMS.WebHost/Locale/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1542,4 +1542,5 @@ View Video Category: 查看視頻類別
Manage Video Category: 管理視頻類別
Video(Embed): 視頻(嵌入)
Name already exists: 名稱已存在
Please upload video or input video code: 請上傳視頻或者輸入視頻程式碼
Please upload video or input video code: 請上傳視頻或者輸入視頻程式碼
Deleted: 已删除
2 changes: 2 additions & 0 deletions src/ZKEACMS.WebHost/Views/Page/Design.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
{
foreach (var widgetPart in Model.ZoneWidgets[zoneId].OrderBy(m => m.Widget.Position).ThenBy(m => m.Widget.WidgetName))
{
if (widgetPart.Widget.Status == (int)WidgetStatus.Deleted) continue;

if (widgetPart.Widget.ID.IsNotNullAndWhiteSpace())
{
@await Html.DesignWidget(new DesignWidgetViewModel(widgetPart, Model.Page.ID))
Expand Down
21 changes: 13 additions & 8 deletions src/ZKEACMS.WebHost/Views/Page/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
</div><!-- /.modal -->
@using (Script.AtFoot())
{
<script type="text/javascript">
<script type="text/javascript">
function Create(node) {
var parent = node.reference.attr("id");
window.location.href = '@Url.Action("Create", "Page")' + '?ParentID=' + parent;
Expand Down Expand Up @@ -139,9 +139,10 @@
Easy.Block();
$.post('@Url.Action("Publish")', { id: id }, function (data) {
if (data.errorMessage) {
Easy.ShowMessageBox("@L("Notice")",data.errorMessage);
Easy.ShowMessageBox("@L("Notice")", data.errorMessage);
}
$(".jstree").jstree().refresh();
$(".simplePreview .widget.disabled").remove();
Easy.UnBlock();
});
}, true);
Expand Down Expand Up @@ -172,24 +173,28 @@
$(document).on("click", ".fullRowList .delete", function () {
var id = $(this).data("widgetid");
Easy.ShowMessageBox("@L("Notice")", "@L("Do you want to delete?")", function () {
$.post("@Url.Action("DeleteWidget", "Widget")", { ID: id }, function (data) {
if (data) {
$.post("@Url.Action("DeleteWidget", "Widget")", { ID: id, permanent: true }, function (data) {
if (data.actionType == @((int)ActionType.Delete)) {
$("#widget_" + id).remove();
} else if (data.actionType == @((int)ActionType.Update)) {
$("#widget_" + id).addClass("disabled");
}
}, "json");
}, true, 10);
}).on("click", ".publish-page",function() {
}).on("click", ".publish-page", function () {
var btn = $(this);
Publish({
reference: {
attr: function (id) {
return btn.data(id);
}}});
return btn.data(id);
}
}
});
});
if (!location.hash) {
location.hash = '@(pageId)';
}
</script>
</script>
<script type="text/javascript">
$(function () {
$(".jstree").css("max-height", $(window).height() - 200).css("overflow", "auto");
Expand Down
4 changes: 2 additions & 2 deletions src/ZKEACMS.WebHost/Views/Page/PageZones.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<ul data-zoneid="@item.HeadingCode" class="fullRowList widgets connectedSortable">
@foreach (var widget in Model.Widgets.Where(m => m.IsInZone(item.HeadingCode)).OrderBy(m => m.Position).ThenBy(m => m.WidgetName))
{
<li id="[email protected]" class="widget" data-widgetid="@widget.ID" data-position="@(widget.LayoutId.IsNotNullAndWhiteSpace()||widget.RuleID.HasValue?widget.Position:0)">
<li title="@(widget.Status == (int)WidgetStatus.Deleted ? L("Deleted"):widget.WidgetName)" id="[email protected]" class="widget @(widget.Status == (int)WidgetStatus.Deleted? "disabled":"")" data-widgetid="@widget.ID" data-position="@(widget.LayoutId.IsNotNullAndWhiteSpace() || widget.RuleID.HasValue ? widget.Position : 0)">
@if (widget.LayoutId.IsNotNullAndWhiteSpace())
{
<a class="badge" href="@Url.Action("LayoutWidget","Layout",new{ layoutId = widget.LayoutId })">@L("Layout")</a>
Expand All @@ -80,7 +80,7 @@
<img class="icon" src="~/images/icons/delete.svg" />
</a>
}
@if (widget.Status == (int)RecordStatus.InActive)
@if (widget.Status == (int)WidgetStatus.Hidden)
{
<a style="cursor:default"><img class="icon" src="~/images/icons/invisible.svg" title="@L("Invisible")" /></a>
}
Expand Down
25 changes: 18 additions & 7 deletions src/ZKEACMS.WebHost/wwwroot/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,9 @@ a.badge:hover {
.fullRowList .glyphicon {
font-size: 12px;
}
.fullRowList .icon{
width:16px;

.fullRowList .icon {
width: 16px;
}

.fullRowList.tags input {
Expand Down Expand Up @@ -391,6 +392,15 @@ a.badge:hover {
color: #E28271;
}

.fullRowList li.disabled {
border-left: 5px solid #ddd;
color: #ccc;
}

.fullRowList li.disabled .icon {
opacity: 0.2;
}

#layouts.fullRowList li {
cursor: pointer;
}
Expand Down Expand Up @@ -577,7 +587,7 @@ a.badge:hover {
text-align: center;
}

#media-list .thumbnail > a.img-link.confirm img{
#media-list .thumbnail > a.img-link.confirm img {
background: url(../images/opacity-dotted.png);
}

Expand Down Expand Up @@ -782,9 +792,9 @@ a.pack-theme {
}
}

.seach-terms .form-control.required {
background-color: #fff;
}
.seach-terms .form-control.required {
background-color: #fff;
}

.dataTable tfoot .search {
display: none;
Expand All @@ -793,6 +803,7 @@ a.pack-theme {
.select2-container--default .select2-selection--single {
border-color: #ccc;
}

.opacity-dotted {
background: url(../images/opacity-dotted.png);
}
}
2 changes: 1 addition & 1 deletion src/ZKEACMS.WebHost/wwwroot/css/admin.min.css

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/ZKEACMS.WebHost/wwwroot/js/PageDesign.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ $(function () {

$(".templates ul li").draggable({ helper: "clone", connectToSortable: ".zone" });
$(document).on("click", ".zoneToolbar .delete", function () {
var th = $(this);
$.post(th.data("url"), { ID: th.data("id") }, function (data) {
var th = $(this);
var id = th.data("id");
$.post(th.data("url"), { ID: id }, function (data) {
if (data) {
$("#widget_" + data).parent().remove();
$("#widget_" + id).parent().remove();
}
}, "json");
}).on("click", ".zoneToolbar .more", function () {
Expand Down
2 changes: 1 addition & 1 deletion src/ZKEACMS.WebHost/wwwroot/js/PageDesign.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions src/ZKEACMS/Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ public class Const
{
public const string CopyWidgetCookie = "F84DBA";
}

public class DictionaryKeys
{
public const string WidgetStatus = "WidgetStatus";
}
public class Layouts
{
/// <summary>
Expand Down Expand Up @@ -103,7 +106,12 @@ public enum MediaType
Ppt = 9,
Other = 100
}

public enum WidgetStatus
{
Visible = 1,
Hidden = 2,
Deleted = 3
}
public static class FileExtensions
{
public static HashSet<string> Video = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { ".mp4", ".avi", ".rmvb", ".flv", ".wmv", ".asf", ".asx", ".rm", ".3gp", ".mov", ".m4v", ".mkv", ".vob" };
Expand Down
17 changes: 12 additions & 5 deletions src/ZKEACMS/Controllers/WidgetController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,22 @@ public JsonResult SaveWidgetZone([FromBody] List<WidgetBase> widgets)
return Json(true);
}
[HttpPost]
public JsonResult DeleteWidget(string ID)
public JsonResult DeleteWidget(string ID, bool? permanent)
{
WidgetBase widget = _widgetService.Get(ID);
if (widget != null)
var widget = _widgetService.Get(ID);
if (widget == null) return Json(new { ActionType = (int)ActionType.UnAttach });

if (widget.Status == (int)WidgetStatus.Deleted || permanent == true)
{
_widgetActivator.Create(widget).DeleteWidget(ID);
return Json(ID);
return Json(new { ActionType = (int)ActionType.Delete });
}
else
{
widget.Status = (int)WidgetStatus.Deleted;
_widgetService.Update(widget);
return Json(new { ActionType = (int)ActionType.Update });
}
return Json(false);
}

public PartialViewResult Templates()
Expand Down
Loading

0 comments on commit 96a62b5

Please sign in to comment.