Document endpoints of a property and the main image

The document list, upload checks and storage path, detaching, linking an existing document with role rules, and setting the main image.

Property documents are linked through the document centre relation (doc_link, object_type = property); storage goes through the document centre's central path. Every document action requires content scope for the document's company.

List

docs (list permission, GET property_id): document/document::getDocsForObject('property', id), only documents of companies within the user's content scope. A document with a role from Dlbtproperty::DOC_ROLES goes to its slot, other images to the gallery, other non-images to "Other documents". The main image (cover_doc_id) comes first. Each item has an open URL (document/document.preview), images have thumbnail URLs (480, 960, 2048 px), and with edit a detach URL.

Upload

  1. docupload (edit; POST property_id, doc_role, file), one request per file, sent sequentially by the client.
  2. Checks: unsaved property; unknown role (DOC_ROLES + photo + attachment); empty POST (post_max_size); failed file; neither owner nor operator; document owner company outside scope; for photo a non-image (jpg, jpeg, png, gif, webp).
  3. Storage: Dlbtdocstore::addDocument() (file name normalised to ASCII, company_id = owner, otherwise operator, object_type = property, doc_role); read back with getDoc(); success: "Document uploaded.".

Document roles: safety_report, energy_certificate, land_registry, floor_plan, attachment, plus photo.

Detaching and linking

  • docunlink (edit): only for an existing document linked to the property whose company is in scope; deleteDocLink(), the document remains.
  • Linking an existing document (edit, for several documents bulkedit): search through document/folders.docsearch&ctx=property (at least 2 characters), link through document/document.addlink&ctx=property with the slot's role. Role rule: photo only for images (other files as attachment), and only a document with an empty, general or property role is re-classified.
  • The Documents list header has an "Assign to property" bulk button: it requires the labelling permission and the property list permission.

Main image

cover (edit; GET property_id, doc_id; doc_id = 0 clears): only an image linked to the property and within scope. Without migration 20261031_008 a descriptive error; on read-back mismatch "The main image was not saved (read-back mismatch).". With cover_doc_id = 0 the first gallery image is the cover. The gallery shows 12 images by default; an image opens in the shared viewer (pdf.js for PDF if installed).

Data room

The data room shows the main image, the gallery and — only within the user's shared folder — the documents (getPropertyForView(): active property assigned to the current store).