mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
EmberJS: FolderID to SpaceID
Co-Authored-By: Harvey Kandola <harvey@documize.com>
This commit is contained in:
parent
66d5e73ed1
commit
e0457b40da
45 changed files with 170 additions and 99 deletions
|
@ -121,16 +121,16 @@ func (h *Handler) GetBySpace(w http.ResponseWriter, r *http.Request) {
|
|||
method := "block.space"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
folderID := request.Param(r, "folderID")
|
||||
if len(folderID) == 0 {
|
||||
response.WriteMissingDataError(w, method, "folderID")
|
||||
spaceID := request.Param(r, "spaceID")
|
||||
if len(spaceID) == 0 {
|
||||
response.WriteMissingDataError(w, method, "spaceID")
|
||||
return
|
||||
}
|
||||
|
||||
var b []block.Block
|
||||
var err error
|
||||
|
||||
b, err = h.Store.Block.GetBySpace(ctx, folderID)
|
||||
b, err = h.Store.Block.GetBySpace(ctx, spaceID)
|
||||
|
||||
if len(b) == 0 {
|
||||
b = []block.Block{}
|
||||
|
|
|
@ -51,9 +51,9 @@ func (h *Handler) upload(w http.ResponseWriter, r *http.Request) (string, string
|
|||
method := "conversion.upload"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
folderID := request.Param(r, "folderID")
|
||||
spaceID := request.Param(r, "spaceID")
|
||||
|
||||
if !permission.CanUploadDocument(ctx, *h.Store, folderID) {
|
||||
if !permission.CanUploadDocument(ctx, *h.Store, spaceID) {
|
||||
response.WriteForbiddenError(w)
|
||||
return "", "", ""
|
||||
}
|
||||
|
@ -92,10 +92,10 @@ func (h *Handler) upload(w http.ResponseWriter, r *http.Request) (string, string
|
|||
|
||||
h.Runtime.Log.Info(fmt.Sprintf("Org %s (%s) [Uploaded] %s", ctx.OrgName, ctx.OrgID, filename.Filename))
|
||||
|
||||
return job, folderID, ctx.OrgID
|
||||
return job, spaceID, ctx.OrgID
|
||||
}
|
||||
|
||||
func (h *Handler) convert(w http.ResponseWriter, r *http.Request, job, folderID string, conversion api.ConversionJobRequest) {
|
||||
func (h *Handler) convert(w http.ResponseWriter, r *http.Request, job, spaceID string, conversion api.ConversionJobRequest) {
|
||||
method := "conversion.upload"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
|
@ -145,7 +145,7 @@ func (h *Handler) convert(w http.ResponseWriter, r *http.Request, job, folderID
|
|||
}
|
||||
|
||||
// Fetch space where document resides.
|
||||
sp, err := h.Store.Space.Get(ctx, folderID)
|
||||
sp, err := h.Store.Space.Get(ctx, spaceID)
|
||||
if err != nil {
|
||||
ctx.Transaction.Rollback()
|
||||
response.WriteServerError(w, method, err)
|
||||
|
|
|
@ -29,12 +29,12 @@ type Handler struct {
|
|||
|
||||
// UploadConvert is an endpoint to both upload and convert a document
|
||||
func (h *Handler) UploadConvert(w http.ResponseWriter, r *http.Request) {
|
||||
job, folderID, orgID := h.upload(w, r)
|
||||
job, spaceID, orgID := h.upload(w, r)
|
||||
if job == "" {
|
||||
return // error already handled
|
||||
}
|
||||
|
||||
h.convert(w, r, job, folderID, api.ConversionJobRequest{
|
||||
h.convert(w, r, job, spaceID, api.ConversionJobRequest{
|
||||
Job: job,
|
||||
IndexDepth: 4,
|
||||
OrgID: orgID,
|
||||
|
|
|
@ -39,9 +39,9 @@ func (h *Handler) GetLinkCandidates(w http.ResponseWriter, r *http.Request) {
|
|||
method := "link.Candidates"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
folderID := request.Param(r, "folderID")
|
||||
if len(folderID) == 0 {
|
||||
response.WriteMissingDataError(w, method, "folderID")
|
||||
spaceID := request.Param(r, "spaceID")
|
||||
if len(spaceID) == 0 {
|
||||
response.WriteMissingDataError(w, method, "spaceID")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ func (h *Handler) GetLinkCandidates(w http.ResponseWriter, r *http.Request) {
|
|||
if p.RefID != pageID {
|
||||
c := link.Candidate{
|
||||
RefID: uniqueid.Generate(),
|
||||
SpaceID: folderID,
|
||||
SpaceID: spaceID,
|
||||
DocumentID: documentID,
|
||||
TargetID: p.RefID,
|
||||
LinkType: p.Type,
|
||||
|
@ -109,7 +109,7 @@ func (h *Handler) GetLinkCandidates(w http.ResponseWriter, r *http.Request) {
|
|||
for _, f := range files {
|
||||
c := link.Candidate{
|
||||
RefID: uniqueid.Generate(),
|
||||
SpaceID: folderID,
|
||||
SpaceID: spaceID,
|
||||
DocumentID: documentID,
|
||||
TargetID: f.RefID,
|
||||
LinkType: "file",
|
||||
|
|
|
@ -53,13 +53,13 @@ func (h *Handler) SavedList(w http.ResponseWriter, r *http.Request) {
|
|||
method := "template.saved"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
folderID := request.Param(r, "folderID")
|
||||
if len(folderID) == 0 {
|
||||
response.WriteMissingDataError(w, method, "folderID")
|
||||
spaceID := request.Param(r, "spaceID")
|
||||
if len(spaceID) == 0 {
|
||||
response.WriteMissingDataError(w, method, "spaceID")
|
||||
return
|
||||
}
|
||||
|
||||
documents, err := h.Store.Document.TemplatesBySpace(ctx, folderID)
|
||||
documents, err := h.Store.Document.TemplatesBySpace(ctx, spaceID)
|
||||
if err != nil {
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
|
@ -77,7 +77,7 @@ func (h *Handler) SavedList(w http.ResponseWriter, r *http.Request) {
|
|||
t.Dated = d.Created
|
||||
t.Type = template.TypePrivate
|
||||
|
||||
if d.SpaceID == folderID {
|
||||
if d.SpaceID == spaceID {
|
||||
templates = append(templates, t)
|
||||
}
|
||||
}
|
||||
|
@ -266,9 +266,9 @@ func (h *Handler) Use(w http.ResponseWriter, r *http.Request) {
|
|||
method := "template.use"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
folderID := request.Param(r, "folderID")
|
||||
if len(folderID) == 0 {
|
||||
response.WriteMissingDataError(w, method, "folderID")
|
||||
spaceID := request.Param(r, "spaceID")
|
||||
if len(spaceID) == 0 {
|
||||
response.WriteMissingDataError(w, method, "spaceID")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ func (h *Handler) Use(w http.ResponseWriter, r *http.Request) {
|
|||
d.Excerpt = "Add detailed description for document..."
|
||||
d.Slug = stringutil.MakeSlug(d.Name)
|
||||
d.Tags = ""
|
||||
d.SpaceID = folderID
|
||||
d.SpaceID = spaceID
|
||||
documentID := uniqueid.Generate()
|
||||
d.RefID = documentID
|
||||
|
||||
|
@ -321,7 +321,7 @@ func (h *Handler) Use(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
// Fetch space where document resides.
|
||||
sp, err := h.Store.Space.Get(ctx, folderID)
|
||||
sp, err := h.Store.Space.Get(ctx, spaceID)
|
||||
if err != nil {
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
|
@ -339,7 +339,7 @@ func (h *Handler) Use(w http.ResponseWriter, r *http.Request) {
|
|||
documentID = uniqueid.Generate()
|
||||
d.RefID = documentID
|
||||
d.Template = false
|
||||
d.SpaceID = folderID
|
||||
d.SpaceID = spaceID
|
||||
d.UserID = ctx.UserID
|
||||
d.Name = docTitle
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue