|
|
|
|
@@ -2,10 +2,14 @@ package be.seeseepuff.pcinv.controllers;
|
|
|
|
|
|
|
|
|
|
import be.seeseepuff.pcinv.services.AssetService;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Controller for handling web requests related to assets.
|
|
|
|
|
@@ -51,4 +55,21 @@ public class WebController {
|
|
|
|
|
model.addAttribute(DESCRIPTOR, assetService.getAssetDescriptor(type));
|
|
|
|
|
return "create_asset";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handles the form submission for creating an asset.
|
|
|
|
|
*
|
|
|
|
|
* @param model The model to add attributes to.
|
|
|
|
|
* @param type The type of asset to create.
|
|
|
|
|
* @return The view name for creating the asset.
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping(
|
|
|
|
|
value = "/create/{type}",
|
|
|
|
|
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE
|
|
|
|
|
)
|
|
|
|
|
public String createTypePost(Model model, @PathVariable String type, @RequestBody MultiValueMap<String, String> formData) {
|
|
|
|
|
model.addAttribute(DESCRIPTORS, assetService.getAssetDescriptorTree(type));
|
|
|
|
|
model.addAttribute(DESCRIPTOR, assetService.getAssetDescriptor(type));
|
|
|
|
|
return "create_asset";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|