Skip to content

Commit a45159b

Browse files
committed
newtab fields
1 parent 7bf41ba commit a45159b

File tree

4 files changed

+7992
-9608
lines changed

4 files changed

+7992
-9608
lines changed

gen-esign/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func main() {
7272
}
7373
structName = def.Name
7474
}
75+
7576
// create templates
7677
if !strings.HasPrefix(*templDir, "/") {
7778
*templDir = path.Join(*baseDir, *templDir)
@@ -171,7 +172,7 @@ func doModel(modelTempl *template.Template, defList []Definition, defMap map[str
171172
}()
172173
// get field overrides and tab overrides
173174
fldOverrides := GetFieldOverrides()
174-
tabDefs := TabDefs(defMap, fldOverrides)
175+
tabDefs := V21TabDefs(defMap, fldOverrides)
175176
var data = struct {
176177
Definitions []Definition
177178
DefMap map[string]Definition

gen-esign/overrides.go

+251-2
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,202 @@ func GetDownloadAdditions(opID string) []DownloadAddition {
12551255
// TabDefs creates a list definitions for embedded tab structs from the defMap parameter.
12561256
// overrides is updated with new override entries to allow tab definitions to generate.
12571257
func TabDefs(defMap map[string]Definition, overrides map[string]map[string]string) []Definition {
1258+
// list of tab objects
1259+
var tabObjects = []string{
1260+
"approve",
1261+
"checkbox",
1262+
"company",
1263+
"dateSigned",
1264+
"date",
1265+
"decline",
1266+
"emailAddress",
1267+
"email",
1268+
"envelopeId",
1269+
"firstName",
1270+
"formulaTab",
1271+
"fullName",
1272+
"initialHere",
1273+
"lastName",
1274+
"list",
1275+
"notarize",
1276+
"note",
1277+
"number",
1278+
"radioGroup",
1279+
"signerAttachment",
1280+
"signHere",
1281+
"ssn",
1282+
"text",
1283+
"tabGroup",
1284+
"title",
1285+
"view",
1286+
"zip",
1287+
}
1288+
1289+
// list of types of tabs
1290+
tabDefs := map[string]Definition{
1291+
"Base": {
1292+
ID: "TabBase",
1293+
Name: "TabBase",
1294+
Type: "Object",
1295+
Description: "contains common fields for all tabs",
1296+
Summary: "contains common fields for all tabs",
1297+
Category: "",
1298+
},
1299+
"Position": {
1300+
ID: "TabPosition",
1301+
Name: "TabPosition",
1302+
Type: "Object",
1303+
Description: "contains common fields for all tabs that can position themselves on document",
1304+
Summary: "contains common fields for all tabs that can position themselves on document",
1305+
Category: "",
1306+
},
1307+
"Style": {
1308+
ID: "TabStyle",
1309+
Name: "TabStyle",
1310+
Type: "Object",
1311+
Description: "contains common fields for all tabs that can set a display style",
1312+
Summary: "contains common fields for all tabs that can set a display style",
1313+
Category: "",
1314+
},
1315+
"Value": {
1316+
ID: "TabValue",
1317+
Name: "TabValue",
1318+
Type: "Object",
1319+
Description: "add Value() func to tab",
1320+
Summary: "add Value() func to tab",
1321+
Category: "",
1322+
},
1323+
}
1324+
// list of fields for each tab type
1325+
tabFields := map[string][]string{
1326+
"Base": {
1327+
"conditionalParentLabel",
1328+
"conditionalParentValue",
1329+
"documentId",
1330+
"recipientId",
1331+
},
1332+
"Position": {
1333+
"anchorCaseSensitive",
1334+
"anchorHorizontalAlignment",
1335+
"anchorIgnoreIfNotPresent",
1336+
"anchorMatchWholeWord",
1337+
"anchorString",
1338+
"anchorUnits",
1339+
"anchorXOffset",
1340+
"anchorYOffset",
1341+
"customTabId",
1342+
"errorDetails",
1343+
"mergeField",
1344+
"pageNumber",
1345+
"status",
1346+
"tabId",
1347+
"tabLabel",
1348+
"tabOrder",
1349+
"templateLocked",
1350+
"templateRequired",
1351+
"xPosition",
1352+
"yPosition",
1353+
},
1354+
"Style": {
1355+
"bold",
1356+
"boldMetadata",
1357+
"font",
1358+
"fontMetadata",
1359+
"fontColor",
1360+
"fontColorMetadata",
1361+
"fontSize",
1362+
"fontSizeMetadata",
1363+
"italic",
1364+
"italicMetadata",
1365+
"name",
1366+
"nameMetadata",
1367+
"underline",
1368+
"underlineMetadata",
1369+
},
1370+
"Value": {
1371+
"value",
1372+
"valueMetadata",
1373+
},
1374+
}
1375+
// loop thru each tab definition
1376+
for _, tabname := range tabObjects {
1377+
dx := defMap["#/definitions/"+tabname]
1378+
// create map of fields for easy lookup
1379+
xmap := make(map[string]bool)
1380+
// NOTE: add tabLabel to notary and name to view.
1381+
//This seems to be an error in swagger definition.
1382+
// TODO: remove when fixed in swagger file
1383+
if tabname == "notarize" {
1384+
xmap["tabLabel"] = true
1385+
}
1386+
if tabname == "view" {
1387+
xmap["name"] = true
1388+
}
1389+
1390+
for _, f := range dx.Fields {
1391+
xmap[f.Name] = true
1392+
}
1393+
// Get Overrides for this tab definition
1394+
defOverrides, ok := overrides[dx.ID]
1395+
if !ok {
1396+
defOverrides = make(map[string]string)
1397+
overrides[dx.ID] = defOverrides
1398+
}
1399+
memberOf := make([]string, 0) // tab types for this tab
1400+
// Loop thru each tab type
1401+
for _, nm := range []string{"Base", "Position", "Style", "Value"} {
1402+
// check for match by checking for existence of each field
1403+
isType := true
1404+
for _, s := range tabFields[nm] {
1405+
if isType = xmap[s]; !isType {
1406+
break
1407+
}
1408+
}
1409+
// if match, mark override for each field
1410+
if isType {
1411+
for _, f := range tabFields[nm] {
1412+
// Definition.StructFields() will know to skip
1413+
// outputting this field for the type def
1414+
defOverrides[f] = "-"
1415+
}
1416+
memberOf = append(memberOf, "Tab"+nm)
1417+
}
1418+
}
1419+
// create override. Definition.StructFields will know to output
1420+
// these embedded types.
1421+
if len(memberOf) > 0 {
1422+
defOverrides["TABS"] = strings.Join(memberOf, ",")
1423+
}
1424+
}
1425+
1426+
// Get field definitions for embedded types. Assume that
1427+
// the Text tab meets all definitions so copy appropriate field
1428+
// from its definition
1429+
txtDef := defMap["#/definitions/text"]
1430+
xmap := make(map[string]Field)
1431+
for _, f := range txtDef.Fields {
1432+
xmap[f.Name] = f
1433+
1434+
}
1435+
results := make([]Definition, 0)
1436+
for _, tabDefName := range []string{"Base", "Position", "Style", "Value"} {
1437+
ndef := tabDefs[tabDefName]
1438+
for _, s := range tabFields[tabDefName] {
1439+
fx, ok := xmap[s]
1440+
if ok {
1441+
ndef.Fields = append(ndef.Fields, fx)
1442+
}
1443+
}
1444+
results = append(results, ndef)
1445+
1446+
}
1447+
// return list of embedded tab definitions
1448+
return results
1449+
}
1450+
1451+
// V21TabDefs creates a list definitions for embedded tab structs from the defMap parameter.
1452+
// overrides is updated with new override entries to allow tab definitions to generate.
1453+
func V21TabDefs(defMap map[string]Definition, overrides map[string]map[string]string) []Definition {
12581454
// list of tab objects
12591455
var tabObjects = []string{
12601456
"approve",
@@ -1299,6 +1495,14 @@ func TabDefs(defMap map[string]Definition, overrides map[string]map[string]strin
12991495
Summary: "contains common fields for all tabs",
13001496
Category: "",
13011497
},
1498+
"GuidedForm": {
1499+
ID: "TabGuidedForm",
1500+
Name: "TabGuidedForm",
1501+
Type: "Object",
1502+
Description: "contains common fields for all text box tabs",
1503+
Summary: "contains common fields for all text box tabs",
1504+
Category: "",
1505+
},
13021506
"Position": {
13031507
ID: "TabPosition",
13041508
Name: "TabPosition",
@@ -1328,31 +1532,69 @@ func TabDefs(defMap map[string]Definition, overrides map[string]map[string]strin
13281532
tabFields := map[string][]string{
13291533
"Base": {
13301534
"conditionalParentLabel",
1535+
"conditionalParentLabelMetadata",
13311536
"conditionalParentValue",
1537+
"conditionalParentValueMetadata",
13321538
"documentId",
1539+
"documentIdMetadata",
13331540
"recipientId",
1541+
"recipientIdMetadata",
1542+
"recipientIdGuid",
1543+
"recipientIdGuidMetadata",
1544+
"tabGroupLabels",
1545+
"tabGroupLabelsMetadata",
1546+
"tabType",
1547+
"tabTypeMetadata",
1548+
},
1549+
"GuidedForm": {
1550+
"formOrder",
1551+
"formOrderMetadata",
1552+
"formPageLabel",
1553+
"formPageLabelMetadata",
1554+
"formPageNumber",
1555+
"formPageNumberMetadata",
13341556
},
13351557
"Position": {
13361558
"anchorCaseSensitive",
1559+
"anchorCaseSensitiveMetadata",
13371560
"anchorHorizontalAlignment",
1561+
"anchorHorizontalAlignmentMetadata",
13381562
"anchorIgnoreIfNotPresent",
1563+
"anchorIgnoreIfNotPresentMetadata",
13391564
"anchorMatchWholeWord",
1565+
"anchorMatchWholeWordMetadata",
13401566
"anchorString",
1567+
"anchorStringMetadata",
1568+
"anchorTabProcessorVersion",
1569+
"anchorTabProcessorVersionMetadata",
13411570
"anchorUnits",
1571+
"anchorUnitsMetadata",
13421572
"anchorXOffset",
1573+
"anchorXOffsetMetadata",
13431574
"anchorYOffset",
1575+
"anchorYOffsetMetadata",
13441576
"customTabId",
1577+
"customTabIdMetadata",
13451578
"errorDetails",
13461579
"mergeField",
13471580
"pageNumber",
1581+
"pageNumberMetadata",
13481582
"status",
1583+
"statusMetadata",
13491584
"tabId",
1585+
"tabIdMetadata",
13501586
"tabLabel",
1587+
"tabLabelMetadata",
13511588
"tabOrder",
1589+
"tabOrderMetadata",
13521590
"templateLocked",
1591+
"templateLockedMetadata",
13531592
"templateRequired",
1593+
"templateRequiredMetadata",
13541594
"xPosition",
1595+
"xPositionMetadata",
13551596
"yPosition",
1597+
"yPositionMetadata",
13561598
},
13571599
"Style": {
13581600
"bold",
@@ -1381,6 +1623,10 @@ func TabDefs(defMap map[string]Definition, overrides map[string]map[string]strin
13811623
if tabname == "view" {
13821624
xmap["name"] = true
13831625
}
1626+
if tabname == "radioGroup" {
1627+
xmap["tabGroupLabels"] = true
1628+
xmap["tabGroupLabelsMetadata"] = true
1629+
}
13841630

13851631
for _, f := range dx.Fields {
13861632
xmap[f.Name] = true
@@ -1393,7 +1639,7 @@ func TabDefs(defMap map[string]Definition, overrides map[string]map[string]strin
13931639
}
13941640
memberOf := make([]string, 0) // tab types for this tab
13951641
// Loop thru each tab type
1396-
for _, nm := range []string{"Base", "Position", "Style", "Value"} {
1642+
for _, nm := range []string{"Base", "GuidedForm", "Position", "Style", "Value"} {
13971643
// check for match by checking for existence of each field
13981644
isType := true
13991645
for _, s := range tabFields[nm] {
@@ -1428,7 +1674,7 @@ func TabDefs(defMap map[string]Definition, overrides map[string]map[string]strin
14281674

14291675
}
14301676
results := make([]Definition, 0)
1431-
for _, tabDefName := range []string{"Base", "Position", "Style", "Value"} {
1677+
for _, tabDefName := range []string{"Base", "GuidedForm", "Position", "Style", "Value"} {
14321678
ndef := tabDefs[tabDefName]
14331679
for _, s := range tabFields[tabDefName] {
14341680
fx, ok := xmap[s]
@@ -1479,6 +1725,9 @@ func GetTabValues(tabs Tabs) []NameValue {
14791725
for _, v := range tabs.TextTabs {
14801726
results = append(results, NameValue{Name: v.TabLabel, OriginalValue: v.OriginalValue, Value: v.Value})
14811727
}
1728+
for _, v := range tabs.ZipTabs {
1729+
results = append(results, NameValue{Name: v.TabLabel, OriginalValue: v.OriginalValue, Value: v.Value})
1730+
}
14821731
return results
14831732
}
14841733

gen-esign/swagger.go

+7
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,15 @@ func ToGoNameLC(name string) string {
677677
return strings.ToLower(nm[0:1]) + nm[1:]
678678
}
679679

680+
var registeredGoNames = map[string]bool{
681+
"TabGuidedForm": true,
682+
}
683+
680684
// ToGoName translates a swagger name which can be underscored or camel cased to a name that golint likes
681685
func ToGoName(name string) string {
686+
if _, ok := registeredGoNames[name]; ok {
687+
return name
688+
}
682689
var out []string
683690
for _, w := range split(name) {
684691
uw := strings.ToUpper(w)

0 commit comments

Comments
 (0)