Compare commits
3 Commits
1713bd1f06
...
885d161cf5
Author | SHA1 | Date | |
---|---|---|---|
885d161cf5 | |||
a4a399b812 | |||
2bd4f5921c |
@ -9,6 +9,8 @@ The project also contains reusable Go packages with a Brother QL-series USB
|
|||||||
printer driver and a simple BDF bitmap font renderer, as well as a few related
|
printer driver and a simple BDF bitmap font renderer, as well as a few related
|
||||||
utilities for previewing, printing and debugging.
|
utilities for previewing, printing and debugging.
|
||||||
|
|
||||||
|
image::sklad.png[align="center"]
|
||||||
|
|
||||||
Building and Running
|
Building and Running
|
||||||
--------------------
|
--------------------
|
||||||
Build dependencies: Go +
|
Build dependencies: Go +
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
<p>Chyba: Řadu u neprázdných obalů nelze měnit.
|
<p>Chyba: Řadu u neprázdných obalů nelze měnit.
|
||||||
{{ else if .ErrorCannotChangeNumber }}
|
{{ else if .ErrorCannotChangeNumber }}
|
||||||
<p>Chyba: Číslo obalu v řadě nelze měnit.
|
<p>Chyba: Číslo obalu v řadě nelze měnit.
|
||||||
|
{{ else if .ErrorWouldContainItself }}
|
||||||
|
<p>Chyba: Obal by obsahoval sám sebe.
|
||||||
{{ else if .ErrorContainerInUse }}
|
{{ else if .ErrorContainerInUse }}
|
||||||
<p>Chyba: Obal se používá.
|
<p>Chyba: Obal se používá.
|
||||||
{{ else if .Error }}
|
{{ else if .Error }}
|
||||||
@ -27,7 +29,7 @@
|
|||||||
<small>« <a href="container?id={{ . }}">{{ . }}</a></small>
|
<small>« <a href="container?id={{ . }}">{{ . }}</a></small>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</h2>
|
</h2>
|
||||||
<form method=post action="label?id={{ .Container.Id }}">
|
<form method=post action="label?id={{ .Container.Id }}" target=_blank>
|
||||||
<input type=submit value="Vytisknout štítek">
|
<input type=submit value="Vytisknout štítek">
|
||||||
</form>
|
</form>
|
||||||
<form method=post action="container?id={{ .Container.Id }}&remove">
|
<form method=post action="container?id={{ .Container.Id }}&remove">
|
||||||
@ -99,7 +101,7 @@
|
|||||||
<small>« <a href="container?id={{ . }}">{{ . }}</a></small>
|
<small>« <a href="container?id={{ . }}">{{ . }}</a></small>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</h3>
|
</h3>
|
||||||
<form method=post action="label?id={{ .Id }}">
|
<form method=post action="label?id={{ .Id }}" target=_blank>
|
||||||
<input type=submit value="Vytisknout štítek">
|
<input type=submit value="Vytisknout štítek">
|
||||||
</form>
|
</form>
|
||||||
<form method=post action="container?id={{ .Id }}&remove">
|
<form method=post action="container?id={{ .Id }}&remove">
|
||||||
|
@ -163,6 +163,7 @@ var errNoSuchContainer = errors.New("no such container")
|
|||||||
var errCannotChangeSeriesNotEmpty = errors.New(
|
var errCannotChangeSeriesNotEmpty = errors.New(
|
||||||
"cannot change the series of a non-empty container")
|
"cannot change the series of a non-empty container")
|
||||||
var errCannotChangeNumber = errors.New("cannot change the number")
|
var errCannotChangeNumber = errors.New("cannot change the number")
|
||||||
|
var errWouldContainItself = errors.New("container would contain itself")
|
||||||
var errContainerInUse = errors.New("container is in use")
|
var errContainerInUse = errors.New("container is in use")
|
||||||
|
|
||||||
// Find and filter out the container in O(n).
|
// Find and filter out the container in O(n).
|
||||||
@ -204,19 +205,27 @@ func dbContainerCreate(c *Container) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func dbContainerUpdate(c *Container, updated Container) error {
|
func dbContainerUpdate(c *Container, updated Container) error {
|
||||||
newId := updated.Id()
|
newID := updated.Id()
|
||||||
if updated.Series != c.Series && len(c.Children()) > 0 {
|
if updated.Series != c.Series && len(c.Children()) > 0 {
|
||||||
return errCannotChangeSeriesNotEmpty
|
return errCannotChangeSeriesNotEmpty
|
||||||
}
|
}
|
||||||
if updated.Number != c.Number {
|
if updated.Number != c.Number {
|
||||||
return errCannotChangeNumber
|
return errCannotChangeNumber
|
||||||
}
|
}
|
||||||
if _, ok := indexContainer[newId]; ok && newId != c.Id() {
|
if _, ok := indexContainer[newID]; ok && newID != c.Id() {
|
||||||
return errContainerAlreadyExists
|
return errContainerAlreadyExists
|
||||||
}
|
}
|
||||||
if updated.Parent != c.Parent {
|
if updated.Parent != c.Parent {
|
||||||
|
// Relying on the invariant that we can't change the ID
|
||||||
|
// of a non-empty container.
|
||||||
|
for pv := &updated; pv.Parent != ""; pv = indexContainer[pv.Parent] {
|
||||||
|
if pv.Parent == updated.Id() {
|
||||||
|
return errWouldContainItself
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
indexChildren[c.Parent] = filterContainer(indexChildren[c.Parent], c)
|
indexChildren[c.Parent] = filterContainer(indexChildren[c.Parent], c)
|
||||||
indexChildren[newId] = append(indexChildren[newId], c)
|
indexChildren[newID] = append(indexChildren[newID], c)
|
||||||
}
|
}
|
||||||
*c = updated
|
*c = updated
|
||||||
return dbCommit()
|
return dbCommit()
|
||||||
|
@ -130,6 +130,7 @@ func handleContainer(w http.ResponseWriter, r *http.Request) {
|
|||||||
ErrorNoSuchContainer bool
|
ErrorNoSuchContainer bool
|
||||||
ErrorCannotChangeSeriesNotEmpty bool
|
ErrorCannotChangeSeriesNotEmpty bool
|
||||||
ErrorCannotChangeNumber bool
|
ErrorCannotChangeNumber bool
|
||||||
|
ErrorWouldContainItself bool
|
||||||
ErrorContainerInUse bool
|
ErrorContainerInUse bool
|
||||||
Container *Container
|
Container *Container
|
||||||
Children []*Container
|
Children []*Container
|
||||||
@ -141,6 +142,7 @@ func handleContainer(w http.ResponseWriter, r *http.Request) {
|
|||||||
ErrorNoSuchContainer: err == errNoSuchContainer,
|
ErrorNoSuchContainer: err == errNoSuchContainer,
|
||||||
ErrorCannotChangeSeriesNotEmpty: err == errCannotChangeSeriesNotEmpty,
|
ErrorCannotChangeSeriesNotEmpty: err == errCannotChangeSeriesNotEmpty,
|
||||||
ErrorCannotChangeNumber: err == errCannotChangeNumber,
|
ErrorCannotChangeNumber: err == errCannotChangeNumber,
|
||||||
|
ErrorWouldContainItself: err == errWouldContainItself,
|
||||||
ErrorContainerInUse: err == errContainerInUse,
|
ErrorContainerInUse: err == errContainerInUse,
|
||||||
Container: container,
|
Container: container,
|
||||||
Children: children,
|
Children: children,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user