Skip to content

Commit a2eea34

Browse files
committed
Fixed grid column and row index
1 parent b1b1579 commit a2eea34

File tree

4 files changed

+44
-17
lines changed

4 files changed

+44
-17
lines changed

src/DragonFly.AspNetCore/Interceptors/WebHookInterceptor.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@ public WebHookInterceptor(
2727
/// </summary>
2828
public HttpClient HttpClient { get; }
2929

30-
public ILogger<WebHookInterceptor> Logger { get; }
31-
32-
public async Task OnDeletedAsync(IDataStorage storage, ContentItem contentItem)
33-
{
34-
35-
}
30+
public ILogger<WebHookInterceptor> Logger { get; }
3631

3732
public async Task OnPublishedAsync(IDataStorage storage, ContentItem contentItem)
3833
{
@@ -112,8 +107,18 @@ public async Task OnUnpublishedAsync(IDataStorage storage, ContentItem contentIt
112107
}
113108
}
114109

110+
public async Task OnCreatedAsync(IDataStorage storage, ContentItem contentItem)
111+
{
112+
113+
}
114+
115115
public async Task OnUpdatedAsync(IDataStorage storage, ContentItem contentItem)
116116
{
117-
117+
118+
}
119+
120+
public async Task OnDeletedAsync(IDataStorage storage, ContentItem contentItem)
121+
{
122+
118123
}
119124
}

src/DragonFly.BlockField.Client/Pages/Blocks/GridBlockView.razor

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
{
100100
GridItem currentItem = item;
101101

102-
<div class="grid-item" style="grid-column: @(item.ColumnStart * 2 - 1 + 3) / @(item.ColumnEnd * 2 - 1 + 3); grid-row: @(item.RowStart * 2 + 2) / @(item.RowEnd * 2 + 2)">
102+
<div class="grid-item" style="grid-column: @(CalcPosStart(item.ColumnStart)) / @(CalcPosEnd(item.ColumnEnd)); grid-row: @(CalcPosStart(item.RowStart)) / @(CalcPosEnd(item.RowEnd))">
103103
<div style="display:grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto 1fr auto; width: 100%; height: 100%;">
104104
<!--left-->
105105
<div style="display:flex; flex-direction: column; align-items: stretch; justify-content: center; grid-column: 1; grid-row: 2">
@@ -125,6 +125,10 @@
125125
<div style="display:flex; grid-column: 3; grid-row: 1">
126126
<BSButton Color="BSColor.Light" OnClick="x => Block.Items.Remove(currentItem)" title="Remove block"><i class="fas fa-times"></i></BSButton>
127127
</div>
128+
<!--position-->
129+
<div style="display:flex; grid-column: 1; grid-row: 1; justify-content: center; align-items: center">
130+
<span>@item.ColumnStart / @item.ColumnEnd</span>
131+
</div>
128132
<!--field-->
129133
<div style="display:flex; grid-column: 2; grid-row: 2; align-items:center; justify-content: center">
130134
@ComponentManager.CreateComponent(item.Block)
@@ -147,6 +151,16 @@
147151

148152
}
149153

154+
private int CalcPosStart(int value)
155+
{
156+
return value * 2 + 2;
157+
}
158+
159+
private int CalcPosEnd(int value)
160+
{
161+
return value * 2 + 1;
162+
}
163+
150164
private string GetTemplate(ICollection<GridSpan> spans)
151165
{
152166
List<string> builder = new List<string>(spans.Count * 2 + 3);

src/DragonFly.Core/Interceptors/IContentInterceptor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ namespace DragonFly;
66

77
public interface IContentInterceptor
88
{
9+
Task OnCreatedAsync(IDataStorage storage, ContentItem contentItem);
10+
911
Task OnUpdatedAsync(IDataStorage storage, ContentItem contentItem);
1012

1113
Task OnDeletedAsync(IDataStorage storage, ContentItem contentItem);

src/DragonFly.MongoDB/Storages/MongoStorage.ContentItem.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,27 +194,33 @@ public async Task<QueryResult<ContentItem>> QueryAsync(ContentQuery query)
194194
return queryResult;
195195
}
196196

197-
public async Task CreateAsync(ContentItem contentItem)
197+
public async Task CreateAsync(ContentItem content)
198198
{
199-
if (contentItem.Id == Guid.Empty)
199+
if (content.Id == Guid.Empty)
200200
{
201-
contentItem.Id = Guid.NewGuid();
201+
content.Id = Guid.NewGuid();
202202
}
203203

204204
DateTime now = DateTimeService.Current();
205205

206-
contentItem.CreatedAt = now;
207-
contentItem.ModifiedAt = now;
206+
content.CreatedAt = now;
207+
content.ModifiedAt = now;
208208

209-
var items = GetMongoCollection(contentItem.Schema.Name);
209+
var items = GetMongoCollection(content.Schema.Name);
210210

211-
contentItem.Validate();
211+
content.Validate();
212212

213-
MongoContentItem mongo = contentItem.ToMongo();
213+
MongoContentItem mongo = content.ToMongo();
214214

215215
await items.InsertOneAsync(mongo);
216216

217-
contentItem.Id = mongo.Id;
217+
content.Id = mongo.Id;
218+
219+
//execute interceptors
220+
foreach (IContentInterceptor interceptor in Interceptors)
221+
{
222+
await interceptor.OnCreatedAsync(this, content);
223+
}
218224
}
219225

220226
public async Task UpdateAsync(ContentItem contentItem)

0 commit comments

Comments
 (0)