@@ -144,10 +144,11 @@ extension MeetupId { | |||||
) | ) | ||||
ctrl.pipeValue( | ctrl.pipeValue( | ||||
dbg: "testTUI", | dbg: "testTUI", | ||||
sub: nil, | sub: nil, | ||||
Bus.events.compactMap { Bus.convertKeyValue(K.testTextUI, $0) }.map { (k: String, v: MPAK.Many<String>) in v }.eraseToAnyPublisher(), | |||||
many.eraseToAnyPublisher(), | |||||
{ | { | ||||
$0.testTextUI = $1 | $0.testTextUI = $1 | ||||
}, | }, | ||||
@@ -155,6 +156,8 @@ extension MeetupId { | |||||
) | ) | ||||
} | } | ||||
} | } | ||||
@@ -1,10 +1,17 @@ | |||||
from generation.isPipeMany import * | |||||
from generation.isPipeRecent import * | from generation.isPipeRecent import * | ||||
def fieldFormat(fmtPlain, fmtRecent, name, structure): | |||||
def fieldFormat(fmtMany, fmtPlain, fmtRecent, name, structure): | |||||
fmt = fmtPlain | fmt = fmtPlain | ||||
if ( | if ( | ||||
isPipeRecent(name, structure.core) or | isPipeRecent(name, structure.core) or | ||||
isPipeRecent(name, structure.service) | isPipeRecent(name, structure.service) | ||||
): | ): | ||||
fmt = fmtRecent | fmt = fmtRecent | ||||
if ( | |||||
isPipeMany(name, structure.core) or | |||||
isPipeMany(name, structure.service) | |||||
): | |||||
fmt = fmtMany | |||||
return fmt | return fmt |
@@ -5,11 +5,12 @@ def generateContextFields(c): | |||||
lines = c.readFile(fileName) | lines = c.readFile(fileName) | ||||
fmtPlain = lines[0] | fmtPlain = lines[0] | ||||
fmtRecent = lines[1] | fmtRecent = lines[1] | ||||
fmtMany = lines[2] | |||||
fields = [] | fields = [] | ||||
for key in c.structure.model.fields: | for key in c.structure.model.fields: | ||||
values = c.structure.model.fields[key] | values = c.structure.model.fields[key] | ||||
fmt = fieldFormat(fmtPlain, fmtRecent, key, c.structure) | |||||
fmt = fieldFormat(fmtMany, fmtPlain, fmtRecent, key, c.structure) | |||||
ln = fmt \ | ln = fmt \ | ||||
.replace("%NAME%", key) \ | .replace("%NAME%", key) \ | ||||
.replace("%TYPE%", values[0]) | .replace("%TYPE%", values[0]) | ||||
@@ -5,11 +5,12 @@ def generateModelFields(c): | |||||
lines = c.readFile(fileName) | lines = c.readFile(fileName) | ||||
fmtPlain = lines[0] | fmtPlain = lines[0] | ||||
fmtRecent = lines[1] | fmtRecent = lines[1] | ||||
fmtMany = lines[2] | |||||
fields = [] | fields = [] | ||||
for key in c.structure.model.fields: | for key in c.structure.model.fields: | ||||
values = c.structure.model.fields[key] | values = c.structure.model.fields[key] | ||||
fmt = fieldFormat(fmtPlain, fmtRecent, key, c.structure) | |||||
fmt = fieldFormat(fmtMany, fmtPlain, fmtRecent, key, c.structure) | |||||
ln = fmt \ | ln = fmt \ | ||||
.replace("%NAME%", key) \ | .replace("%NAME%", key) \ | ||||
.replace("%TYPE%", values[0]) \ | .replace("%TYPE%", values[0]) \ | ||||
@@ -0,0 +1,5 @@ | |||||
def isPipeMany(name, entity): | |||||
if name in entity.pipes: | |||||
props = entity.pipes[name] | |||||
return "many" in props | |||||
return False |
@@ -1,5 +1,11 @@ | |||||
from generation.isPipeMany import * | |||||
def pipeBusSource(name, entity, busKey, structure, fmt): | def pipeBusSource(name, entity, busKey, structure, fmt): | ||||
valueType = structure.model.fields[name][0] | valueType = structure.model.fields[name][0] | ||||
if isPipeMany(name, entity): | |||||
itemType = structure.model.fields[key][0] | |||||
valueType = f"MPAK.Many<{itemType}>" | |||||
return fmt \ | return fmt \ | ||||
.replace("%BUS_KEY%", busKey) \ | .replace("%BUS_KEY%", busKey) \ | ||||
.replace("%BUS_VALUE_TYPE%", valueType) | .replace("%BUS_VALUE_TYPE%", valueType) |
@@ -1,6 +1,8 @@ | |||||
def pipeFormat(fmtExRecent, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, name, entity): | |||||
def pipeFormat(fmtExRecent, fmtMany, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, name, entity): | |||||
props = entity.pipes[name] | props = entity.pipes[name] | ||||
if "recent" and "ex" in props: | |||||
if "many" in props: | |||||
return fmtMany | |||||
elif "recent" and "ex" in props: | |||||
return fmtExRecent | return fmtExRecent | ||||
elif "recent" in props: | elif "recent" in props: | ||||
return fmtRecent | return fmtRecent | ||||
@@ -6,6 +6,7 @@ from generation.pipeSource import * | |||||
def sectionGeneratedPipes(entity, sub, c): | def sectionGeneratedPipes(entity, sub, c): | ||||
fmtBusPipe = c.readFile(f"{c.dir}/templates/section-generated-pipe-src-bus")[0] | fmtBusPipe = c.readFile(f"{c.dir}/templates/section-generated-pipe-src-bus")[0] | ||||
fmtExRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-ex-recent") | fmtExRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-ex-recent") | ||||
fmtMany = c.readFile(f"{c.dir}/templates/section-generated-pipe-many") | |||||
fmtRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-recent") | fmtRecent = c.readFile(f"{c.dir}/templates/section-generated-pipe-recent") | ||||
fmtSet = c.readFile(f"{c.dir}/templates/section-generated-pipe-set") | fmtSet = c.readFile(f"{c.dir}/templates/section-generated-pipe-set") | ||||
fmtToggle = c.readFile(f"{c.dir}/templates/section-generated-pipe-toggle") | fmtToggle = c.readFile(f"{c.dir}/templates/section-generated-pipe-toggle") | ||||
@@ -33,7 +34,7 @@ def sectionGeneratedPipes(entity, sub, c): | |||||
if src.startswith("K."): | if src.startswith("K."): | ||||
src = pipeBusSource(key, entity, src, c.structure, fmtBusPipe) | src = pipeBusSource(key, entity, src, c.structure, fmtBusPipe) | ||||
fmtPipe = pipeFormat(fmtExRecent, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, key, entity) | |||||
fmtPipe = pipeFormat(fmtExRecent, fmtMany, fmtRecent, fmtSet, fmtToggle, fmtToggleNil, key, entity) | |||||
for fmt in fmtPipe: | for fmt in fmtPipe: | ||||
ln = fmt \ | ln = fmt \ | ||||
.replace("%EX_NAME%", exName) \ | .replace("%EX_NAME%", exName) \ | ||||
@@ -1,2 +1,3 @@ | |||||
var %NAME%: %TYPE% { get } | var %NAME%: %TYPE% { get } | ||||
var %NAME%: MPAK.Recent<%TYPE%> { get } | var %NAME%: MPAK.Recent<%TYPE%> { get } | ||||
var %NAME%: MPAK.Many<%TYPE%> { get } |
@@ -1,2 +1,3 @@ | |||||
public var %NAME%: %TYPE% = %DEFAULT% | public var %NAME%: %TYPE% = %DEFAULT% | ||||
public var %NAME%: MPAK.Recent<%TYPE%> = .init(%DEFAULT%) | public var %NAME%: MPAK.Recent<%TYPE%> = .init(%DEFAULT%) | ||||
public var %NAME%: MPAK.Many<%TYPE%> = .init() |
@@ -0,0 +1,12 @@ | |||||
ctrl.%PIPE%( | |||||
dbg: "%SHORT_SRC%", | |||||
sub: %SUB%, | |||||
%SRC%.eraseToAnyPublisher(), | |||||
{ | |||||
$0.%NAME% = $1 | |||||
}, | |||||
{ m, _ in m.%NAME%.keys = [] } | |||||
) | |||||
@@ -1,6 +1 @@ | |||||
Bus.events.compactMap { Bus.convertKeyValue(%BUS_KEY%, $0) }.map { (k: String, v: %BUS_VALUE_TYPE%) in v } | Bus.events.compactMap { Bus.convertKeyValue(%BUS_KEY%, $0) }.map { (k: String, v: %BUS_VALUE_TYPE%) in v } | ||||