HTML
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Println("Starting XCPQ Editor Service")
|
log.Println("Starting SimplyCPQ Editor Services")
|
||||||
log.Println("Reading configuration")
|
log.Println("Reading configuration")
|
||||||
config := config.InitConfig("config")
|
config := config.InitConfig("config")
|
||||||
log.Println("Initializing database")
|
log.Println("Initializing database")
|
||||||
@@ -19,5 +19,5 @@ func main() {
|
|||||||
httpServer := server.InitHttpServer(config, dbHandler)
|
httpServer := server.InitHttpServer(config, dbHandler)
|
||||||
httpServer.Start()
|
httpServer.Start()
|
||||||
|
|
||||||
log.Println("XCPQ Editor Service Stopped")
|
log.Println("SimplyCPQ Editor Services Stopped")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func InitHttpServer(config *viper.Viper, dbHandler *sql.DB) HttpServer {
|
|||||||
// static content
|
// static content
|
||||||
router.Static("/static", "../static")
|
router.Static("/static", "../static")
|
||||||
router.GET("/", mainHandler.Home)
|
router.GET("/", mainHandler.Home)
|
||||||
router.GET("/properties/rootnodes", propertyTypeHandler.GetRootPropertyTypeGroups)
|
router.GET("/properties/:id/childs", propertyTypeHandler.GetPropertyTypeGroupContentById)
|
||||||
|
|
||||||
//router.GET("/properties", handler.PropertiesHandler)
|
//router.GET("/properties", handler.PropertiesHandler)
|
||||||
/* old routes
|
/* old routes
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"SimplyCPQ2/internal/services"
|
"SimplyCPQ2/internal/services"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@@ -16,6 +17,40 @@ func NewPropertyTypeHandler(propertyTypeService *services.PropertyTypeService) *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dummy Methode
|
||||||
func (h *PropertyTypeHandler) GetRootPropertyTypeGroups(ctx *gin.Context) {
|
func (h *PropertyTypeHandler) GetRootPropertyTypeGroups(ctx *gin.Context) {
|
||||||
// Implement the logic to get root property types groups here
|
// Implement the logic to get root property types groups here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *PropertyTypeHandler) GetPropertyTypeGroupContentById(ctx *gin.Context) {
|
||||||
|
idParam := ctx.Param("id")
|
||||||
|
// Convert idParam to an integer
|
||||||
|
id, err := strconv.Atoi(idParam)
|
||||||
|
if err != nil {
|
||||||
|
ctx.JSON(400, gin.H{"error": "Invalid ID"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// get property type groups by parent ID
|
||||||
|
ptgs, err := h.propertyTypeService.GetPropertyTypeGroupsByParentId(id)
|
||||||
|
if err != nil {
|
||||||
|
ctx.JSON(500, gin.H{"error": "Failed to get property type group content"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// get property types by parent ID
|
||||||
|
pts, err := h.propertyTypeService.GetPropertyTypesByGroupId(id)
|
||||||
|
if err != nil {
|
||||||
|
ctx.JSON(500, gin.H{"error": "Failed to get property types"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// template for response
|
||||||
|
|
||||||
|
ctx.JSON(200, gin.H{
|
||||||
|
"propertyTypeGroups": ptgs,
|
||||||
|
"propertyTypes": pts,
|
||||||
|
})
|
||||||
|
|
||||||
|
// Implement the logic to get property type group content by ID here using idParam
|
||||||
|
}
|
||||||
|
|||||||
@@ -128,10 +128,10 @@ func (r *PropertyRepository) GetPropertiesByParentPropertyID(pid int) ([]models.
|
|||||||
return properties, nil
|
return properties, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *PropertyRepository) GetPropertiesByPropertyTypeID(pid int) ([]models.Property, error) {
|
func (r *PropertyRepository) GetPropertyByPropertyTypeID(pid int) (models.Property, error) {
|
||||||
rows, err := r.db.Query("SELECT id, name, description, image_url, parent_property_id, property_type_id, product_groups_id, products_id FROM properties WHERE property_type_id = ?", pid)
|
rows, err := r.db.Query("SELECT id, name, description, image_url, parent_property_id, property_type_id, product_groups_id, products_id FROM properties WHERE property_type_id = ?", pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return models.Property{}, err
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ func (r *PropertyRepository) GetPropertiesByPropertyTypeID(pid int) ([]models.Pr
|
|||||||
var property models.Property
|
var property models.Property
|
||||||
err := rows.Scan(&property.Id, &property.Name, &property.Description, &property.ImageURL, &property.ParentPropertyId, &property.PropertyTypeId, &property.ProductGroupId, &property.ProductId)
|
err := rows.Scan(&property.Id, &property.Name, &property.Description, &property.ImageURL, &property.ParentPropertyId, &property.PropertyTypeId, &property.ProductGroupId, &property.ProductId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return models.Property{}, err
|
||||||
}
|
}
|
||||||
if cachedProperty, ok := r.cache[property.Id]; ok {
|
if cachedProperty, ok := r.cache[property.Id]; ok {
|
||||||
properties = append(properties, cachedProperty)
|
properties = append(properties, cachedProperty)
|
||||||
@@ -150,7 +150,10 @@ func (r *PropertyRepository) GetPropertiesByPropertyTypeID(pid int) ([]models.Pr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := rows.Err(); err != nil {
|
if err := rows.Err(); err != nil {
|
||||||
return nil, err
|
return models.Property{}, err
|
||||||
}
|
}
|
||||||
return properties, nil
|
if len(properties) == 0 {
|
||||||
|
return models.Property{}, nil
|
||||||
|
}
|
||||||
|
return properties[0], nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,32 @@ func (r *PropertyTypeGroupRepository) GetPropertyTypeGroupByID(id int) (models.P
|
|||||||
return value, nil
|
return value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *PropertyTypeGroupRepository) GetPropertyTypesByGroupId(gid int) ([]models.PropertyTypeGroup, error) {
|
||||||
|
rows, err := r.db.Query("SELECT id, name, description, parenz_property_typw_goup_id, image_url FROM property_type_groups WHERE parenz_property_typw_goup_id = ?", gid)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
var groups []models.PropertyTypeGroup
|
||||||
|
for rows.Next() {
|
||||||
|
var value models.PropertyTypeGroup
|
||||||
|
err := rows.Scan(&value.Id, &value.Name, &value.Description, &value.ParentPropertyTypeGroupId, &value.ImageURL)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if _, ok := r.cache[value.Id]; !ok {
|
||||||
|
r.cache[value.Id] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
groups = append(groups, value)
|
||||||
|
}
|
||||||
|
if err = rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return groups, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (r *PropertyTypeGroupRepository) CreatePropertyTypeGroup(value models.PropertyTypeGroup) (models.PropertyTypeGroup, error) {
|
func (r *PropertyTypeGroupRepository) CreatePropertyTypeGroup(value models.PropertyTypeGroup) (models.PropertyTypeGroup, error) {
|
||||||
result, err := r.db.Exec("INSERT INTO property_type_groups (name) VALUES (?)", value.Name)
|
result, err := r.db.Exec("INSERT INTO property_type_groups (name) VALUES (?)", value.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,18 +1,41 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"SimplyCPQ2/internal/models"
|
||||||
"SimplyCPQ2/internal/repositories"
|
"SimplyCPQ2/internal/repositories"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PropertyTypeService struct {
|
type PropertyTypeService struct {
|
||||||
// Add any dependencies or fields needed for the service here
|
// Add any dependencies or fields needed for the service here
|
||||||
|
values_Repository *repositories.ValueRepository
|
||||||
|
Property_Repository *repositories.PropertyRepository
|
||||||
PropertyTypes_Repository *repositories.PropertyTypeRepository
|
PropertyTypes_Repository *repositories.PropertyTypeRepository
|
||||||
PropertyTypeGroups_Repository *repositories.PropertyTypeGroupRepository
|
PropertyTypeGroups_Repository *repositories.PropertyTypeGroupRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPropertyTypeService(propertyTypesRepo *repositories.PropertyTypeRepository, propertyTypesGroupsRepo *repositories.PropertyTypeGroupRepository) *PropertyTypeService {
|
func NewPropertyTypeService(propertyRepo *repositories.PropertyRepository, propertyTypesRepo *repositories.PropertyTypeRepository, propertyTypesGroupsRepo *repositories.PropertyTypeGroupRepository, valuesRepo *repositories.ValueRepository) *PropertyTypeService {
|
||||||
return &PropertyTypeService{
|
return &PropertyTypeService{
|
||||||
|
Property_Repository: propertyRepo,
|
||||||
PropertyTypes_Repository: propertyTypesRepo,
|
PropertyTypes_Repository: propertyTypesRepo,
|
||||||
PropertyTypeGroups_Repository: propertyTypesGroupsRepo,
|
PropertyTypeGroups_Repository: propertyTypesGroupsRepo,
|
||||||
|
values_Repository: valuesRepo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Getter functions
|
||||||
|
|
||||||
|
func (service *PropertyTypeService) GetPropertyTypeGroupsByParentId(parentId int) ([]models.PropertyTypeGroup, error) {
|
||||||
|
return service.PropertyTypeGroups_Repository.GetPropertyTypesByGroupId(parentId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *PropertyTypeService) GetPropertyTypesByGroupId(id int) ([]models.PropertyType, error) {
|
||||||
|
return service.PropertyTypes_Repository.GetPropertyTypesByGroupID(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *PropertyTypeService) GetPropertyByTypeId(id int) (models.Property, error) {
|
||||||
|
return service.Property_Repository.GetPropertyByPropertyTypeID(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (service *PropertyTypeService) GetValuesByPropertyId(id int) ([]models.Value, error) {
|
||||||
|
return service.values_Repository.GetValuesByPropertyId(id)
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,157 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="/static/css/scpq_global.css">
|
||||||
|
<link rel="stylesheet" href="/static/css/scpq_header.css">
|
||||||
|
<link rel="stylesheet" href="/static/css/scpq_footer.css">
|
||||||
|
<link rel="stylesheet" href="/static/css/scpq_content.css">
|
||||||
|
<title>Simply CPQ Material Editor V2</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="row">
|
||||||
|
<div class="col-8 col-s-12">
|
||||||
|
<h1>Simply CPQ Material Editor V2</h1>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div class="row">
|
||||||
|
<nav class="col-2 col-s-12">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<details closed>
|
||||||
|
<summary>
|
||||||
|
Eigenschaften
|
||||||
|
</summary>
|
||||||
|
<ul class="node">
|
||||||
|
<li class="leaf"><a href="#">Unterpunkt 1</a></li>
|
||||||
|
<li class="leaf"><a href="#">Unterpunkt 2</a></li>
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<details closed>
|
||||||
|
<summary>
|
||||||
|
Produkte
|
||||||
|
</summary>
|
||||||
|
<ul class="node">
|
||||||
|
<li class="leaf"><a href="#">Unterpunkt 1</a></li>
|
||||||
|
<li class="leaf"><a href="#">Unterpunkt 2</a></li>
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<details closed>
|
||||||
|
<summary>
|
||||||
|
Regeln
|
||||||
|
</summary>
|
||||||
|
<ul class="node">
|
||||||
|
<li class="leaf"><a href="#">Unterpunkt 1</a></li>
|
||||||
|
<li class="leaf"><a href="#">Unterpunkt 2</a></li>
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<details closed>
|
||||||
|
<summary>
|
||||||
|
Preiskalkulation
|
||||||
|
</summary>
|
||||||
|
<ul class="node">
|
||||||
|
<li class="leaf"><a href="#">Unterpunkt 1</a></li>
|
||||||
|
<li class="leaf"><a href="#">Unterpunkt 2</a></li>
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<ul>
|
||||||
|
<details closed>
|
||||||
|
<summary>
|
||||||
|
Übersetzungen
|
||||||
|
</summary>
|
||||||
|
<ul class="node">
|
||||||
|
<li class="leaf"><a href="#">Unterpunkt 1</a></li>
|
||||||
|
<li class="leaf"><a href="#">Unterpunkt 2</a></li>
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<main>
|
||||||
|
<div class="col-6 col-s-6">
|
||||||
|
<h3>Property-Type Group </h3>
|
||||||
|
<section class="editor-view">
|
||||||
|
<section id="PropertyTypeGroupData">
|
||||||
|
<form class="cform" method="post" action="/updatePropertyTypeGroup">
|
||||||
|
<label for="propertyTypeGroupID">ID:</label>
|
||||||
|
<input type="text" id="propertyTypeGroupID" name="propertyTypeGroupID" value="{PropertyTypeGroupID}" disabled>
|
||||||
|
<label for="propertyTypeGroupName">Name:</label>
|
||||||
|
<input type="text" id="propertyTypeGroupName" name="propertyTypeGroupName" value="{PropertyTypeGroupName}">
|
||||||
|
<label for="propertyTypeGroupDescription">Beschreibung:</label>
|
||||||
|
<textarea id="propertyTypeGroupDescription" name="propertyTypeGroupDescription">{PropertyTypeGroupDescription}</textarea>
|
||||||
|
<div class="button_row">
|
||||||
|
<button type="submit">Speichern</button>
|
||||||
|
<button type="submit">Neu</button>
|
||||||
|
<button type="submit">Löschen</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 col-s-12">
|
||||||
|
<div class="aside">
|
||||||
|
<h3>Values für {PropertyTypeName}</h3>
|
||||||
|
<section class="editor-view">
|
||||||
|
<section id="ValueData">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Value</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>1</td>
|
||||||
|
<td>Value 1</td>
|
||||||
|
<td>Description 1</td>
|
||||||
|
<td>
|
||||||
|
<div class="button_row">
|
||||||
|
<button type="button">Edit</button>
|
||||||
|
<button type="button">Delete</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>2</td>
|
||||||
|
<td>Value 2</td>
|
||||||
|
<td>Description 2</td>
|
||||||
|
<td>
|
||||||
|
<div class="button_row">
|
||||||
|
<button type="button">Edit</button>
|
||||||
|
<button type="button">Delete</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div> <!-- Closing the initial row div -->
|
||||||
|
<footer class="row">
|
||||||
|
<div class="col-12 col-s-12">
|
||||||
|
<h6>© 2026 Simply CPQ - All rights reserved - contact: <a href="mailto:Thomas.Sindt@gmx.de">Thomas.Sindt@gmx.de</a></h6>
|
||||||
|
</div>
|
||||||
|
</footer> <!-- Closing the footer row div -->
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
<link rel="stylesheet" href="/static/css/scpq_header.css">
|
<link rel="stylesheet" href="/static/css/scpq_header.css">
|
||||||
<link rel="stylesheet" href="/static/css/scpq_footer.css">
|
<link rel="stylesheet" href="/static/css/scpq_footer.css">
|
||||||
<link rel="stylesheet" href="/static/css/scpq_content.css">
|
<link rel="stylesheet" href="/static/css/scpq_content.css">
|
||||||
|
<script src="/static/js/htmx.js"></script>
|
||||||
<title>Simply CPQ Material Editor V2</title>
|
<title>Simply CPQ Material Editor V2</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -19,15 +20,13 @@
|
|||||||
<nav class="col-2 col-s-12">
|
<nav class="col-2 col-s-12">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<ul>
|
<ul class="node" hx-get="/properties/0/childs" hx-trigger="click" hx-target="#node-0" hx-swap="outerHTML">
|
||||||
<details closed>
|
<details closed>
|
||||||
<summary>
|
<summary>
|
||||||
Eigenschaften
|
Eigenschaften
|
||||||
</summary>
|
</summary>
|
||||||
<ul class="node">
|
<div id="node-0">Keine Informationen vorhanden
|
||||||
<li class="leaf"><a href="#">Unterpunkt 1</a></li>
|
</div>
|
||||||
<li class="leaf"><a href="#">Unterpunkt 2</a></li>
|
|
||||||
</ul>
|
|
||||||
</details>
|
</details>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{{define "ptg_treeNode"}}
|
||||||
|
{{- range .}}
|
||||||
|
<ul class="node" hx-get="/properties/{{.Id}}/childs" hx-trigger="click" hx-target="#node-{{.Id}}" hx-swap="outerHTML">
|
||||||
|
<details closed>
|
||||||
|
<summary>
|
||||||
|
{{.Name}}
|
||||||
|
</summary>
|
||||||
|
<div id="node-{{.Id}}">Keine Informationen vorhanden
|
||||||
|
</div>
|
||||||
|
<ul class="node">
|
||||||
|
{{range .Property_Types}}
|
||||||
|
<li>{{.Name}}</li>
|
||||||
|
{{end}}
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
</ul>
|
||||||
|
{{- end}}
|
||||||
|
{{end}}
|
||||||
Reference in New Issue
Block a user