Class FormStepsRestController

java.lang.Object
sk.iway.iwcm.system.datatable.DatatableRestControllerV2<FormStepEntity,Long>
sk.iway.iwcm.components.multistep_form.rest.FormStepsRestController

@RestController @RequestMapping("/admin/rest/form-steps") @PreAuthorize("@WebjetSecurityService.hasPermission(\'cmp_form\')") public class FormStepsRestController extends DatatableRestControllerV2<FormStepEntity,Long>
Manages form steps in the administration data table.

The controller restricts operations to the current domain and accessible form, maintains duplicated step items, and refreshes the generated form pattern and step positions after structural changes.

  • Constructor Details

  • Method Details

    • getAllItems

      public org.springframework.data.domain.Page<FormStepEntity> getAllItems(org.springframework.data.domain.Pageable pageable)
      Description copied from class: DatatableRestControllerV2
      Ziska z databazy vsetky zaznamy
      Overrides:
      getAllItems in class DatatableRestControllerV2<FormStepEntity,Long>
      Returns:
    • addSpecSearch

      public void addSpecSearch(Map<String,String> params, List<jakarta.persistence.criteria.Predicate> predicates, jakarta.persistence.criteria.Root<FormStepEntity> root, jakarta.persistence.criteria.CriteriaBuilder builder)
      Restricts data-table searches to the requested form.
      Overrides:
      addSpecSearch in class DatatableRestControllerV2<FormStepEntity,Long>
      Parameters:
      params - request search parameters
      predicates - mutable query predicates
      root - query root for form steps
      builder - criteria builder used to create the predicate
    • getOneItem

      public FormStepEntity getOneItem(long id)
      Loads a step for editing or initializes a new step for the requested form.

      The original identifier is copied so the duplicate action can locate its source.

      Overrides:
      getOneItem in class DatatableRestControllerV2<FormStepEntity,Long>
      Parameters:
      id - step identifier, or -1 for a new step
      Returns:
      step prepared for the data-table editor
    • afterSave

      public void afterSave(FormStepEntity entity, FormStepEntity saved)
      Clears cached validation fields and regenerates metadata after saving a step outside duplication.
      Overrides:
      afterSave in class DatatableRestControllerV2<FormStepEntity,Long>
      Parameters:
      entity - submitted step values
      saved - persisted step entity
    • beforeSave

      public void beforeSave(FormStepEntity entity)
      Applies the current domain and temporary position values before persistence.
      Overrides:
      beforeSave in class DatatableRestControllerV2<FormStepEntity,Long>
      Parameters:
      entity - step being saved
    • checkItemPerms

      public boolean checkItemPerms(FormStepEntity entity, Long id)
      Checks that a step belongs to the current domain and an accessible form.

      For existing records, the stored form name is authoritative so a request cannot move a step to a form outside the user's permissions.

      Overrides:
      checkItemPerms in class DatatableRestControllerV2<FormStepEntity,Long>
      Parameters:
      entity - submitted or stored step entity
      id - step identifier, or null for a new step
      Returns:
      true when the current user may operate on the step
    • afterDelete

      public void afterDelete(FormStepEntity entity, long id)
      Removes the deleted step's items and regenerates form metadata.
      Overrides:
      afterDelete in class DatatableRestControllerV2<FormStepEntity,Long>
      Parameters:
      entity - deleted step entity
      id - deleted step identifier
    • beforeDuplicate

      public void beforeDuplicate(FormStepEntity entity)
      Validates the duplicate source and stages copies of its form items.
      Overrides:
      beforeDuplicate in class DatatableRestControllerV2<FormStepEntity,Long>
      Parameters:
      entity - duplicate step submitted by the data table
    • afterDuplicate

      public void afterDuplicate(FormStepEntity entity, Long originalId)
      Assigns staged form items to the duplicated step and regenerates form metadata.
      Overrides:
      afterDuplicate in class DatatableRestControllerV2<FormStepEntity,Long>
      Parameters:
      entity - persisted duplicate step
      originalId - source step identifier
    • getFormStepHtml

      @GetMapping(value="/get-step", params={"form-name","step-id","language"}, produces="text/html") public org.springframework.http.ResponseEntity<String> getFormStepHtml(@RequestParam("form-name") String formName, @RequestParam("step-id") Long stepId, @RequestParam("language") String language, jakarta.servlet.http.HttpServletRequest request)
      Renders one form step for administration preview.
      Parameters:
      formName - logical form name
      stepId - step identifier
      language - requested rendering language
      request - current administration request
      Returns:
      rendered HTML, or an empty bad-request response when rendering fails
    • getCssTemplates

      @GetMapping(value="/css-templates", produces="application/json") public List<LabelValue> getCssTemplates()
    • rowReorder

      @PostMapping(value="/row-reorder", consumes="application/json") public org.springframework.http.ResponseEntity<Boolean> rowReorder(jakarta.servlet.http.HttpServletRequest request, @RequestBody RowReorderDto rowReorderDto)
      Reorders steps and recalculates their form positions after a successful update.
      Overrides:
      rowReorder in class DatatableRestControllerV2<FormStepEntity,Long>
      Parameters:
      request - current administration request
      rowReorderDto - requested data-table row order
      Returns:
      result of the data-table reorder operation
    • checkRowReorderScope

      protected boolean checkRowReorderScope(jakarta.servlet.http.HttpServletRequest request, List<FormStepEntity> entities)
      Verifies that every reordered step belongs to the requested accessible form and domain.
      Overrides:
      checkRowReorderScope in class DatatableRestControllerV2<FormStepEntity,Long>
      Parameters:
      request - current administration request
      entities - steps included in the reorder operation
      Returns:
      true when the complete reorder set is within the permitted scope