mirror of
https://github.com/documize/community.git
synced 2025-07-24 07:39:43 +02:00
clone reusable content blocks
This commit is contained in:
parent
bf390ed0b9
commit
5a2c44717e
1 changed files with 18 additions and 2 deletions
|
@ -128,8 +128,6 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
|
|||
// Get back new space
|
||||
sp, _ = h.Store.Space.Get(ctx, sp.RefID)
|
||||
|
||||
fmt.Println(model)
|
||||
|
||||
// clone existing space?
|
||||
if model.CloneID != "" && (model.CopyDocument || model.CopyPermission || model.CopyTemplate) {
|
||||
ctx.Transaction, err = h.Runtime.Db.Beginx()
|
||||
|
@ -251,6 +249,24 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
if model.CopyTemplate {
|
||||
blocks, err := h.Store.Block.GetBySpace(ctx, model.CloneID)
|
||||
|
||||
for _, b := range blocks {
|
||||
b.RefID = uniqueid.Generate()
|
||||
b.LabelID = sp.RefID
|
||||
b.UserID = ctx.UserID
|
||||
|
||||
err = h.Store.Block.Add(ctx, b)
|
||||
if err != nil {
|
||||
ctx.Transaction.Rollback()
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ctx.Transaction.Commit()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue