| 1 | package equipo |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | |
| 6 | "amadan.net/oficina/equipo/internal/wire" |
| 7 | ) |
| 8 | |
| 9 | // A Design attempt's kept captures as the task page and the direction |
| 10 | // card show them (dynamic specialists spec, sections 3 and 5): grouped by |
| 11 | // option in the report's order, each loaded only from this instance's |
| 12 | // authenticated task-file route. Option names are the specialist's |
| 13 | // labels; the page escapes them like any text. |
| 14 | |
| 15 | // designGallery is what one Design attempt kept, by option. |
| 16 | type designGallery struct { |
| 17 | Options []designOptionView |
| 18 | } |
| 19 | |
| 20 | // designOptionView is one option: its label ("Option 1: Calm") and its |
| 21 | // captures; none when it named none or none was kept. |
| 22 | type designOptionView struct { |
| 23 | Label string |
| 24 | Captures []designCaptureView |
| 25 | } |
| 26 | |
| 27 | // designCaptureView is one kept capture: Src is the task-file route, Alt |
| 28 | // names its option, Tree says which tree it shows. |
| 29 | type designCaptureView struct { |
| 30 | ID, Src, Alt, Tree string |
| 31 | Width, Height int |
| 32 | } |
| 33 | |
| 34 | // galleryOf is the gallery of a task's kept options; nil when there are |
| 35 | // none. |
| 36 | func galleryOf(taskID string, opts []wire.StepDesignOption) *designGallery { |
| 37 | if len(opts) == 0 { |
| 38 | return nil |
| 39 | } |
| 40 | g := &designGallery{} |
| 41 | for i, o := range opts { |
| 42 | ov := designOptionView{Label: fmt.Sprintf(copyText("work.captures.option"), i+1, o.Name)} |
| 43 | for n, c := range o.Captures { |
| 44 | ov.Captures = append(ov.Captures, designCaptureView{ |
| 45 | ID: c.ID, |
| 46 | Src: "/tasks/" + taskID + "/files/" + c.ID, |
| 47 | Alt: fmt.Sprintf(copyText("work.captures.alt"), o.Name, n+1), |
| 48 | Tree: copyText("work.captures.tree." + wire.CaptureTree(c.CaptureID)), |
| 49 | Width: c.Width, |
| 50 | Height: c.Height, |
| 51 | }) |
| 52 | } |
| 53 | g.Options = append(g.Options, ov) |
| 54 | } |
| 55 | return g |
| 56 | } |
| 57 | |