Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

Commit

Permalink
All fields have a label
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Mar 16, 2015
1 parent 029b629 commit 49fb1bf
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion supler/src/main/scala/org/supler/field/ActionField.scala
Expand Up @@ -31,7 +31,6 @@ case class ActionField[T](
val validationScopeJSON = JObject(JField("name", JString(validationScopeJSONData.name)) :: validationScopeJSONData.extra)

JObject(List(
JField(Label, JString(label.getOrElse(""))),
JField(Type, JString(SpecialFieldTypes.Action)),
JField(Path, JString(parentPath.append(name).toString)),
JField("validation_scope", validationScopeJSON)
Expand Down
2 changes: 2 additions & 0 deletions supler/src/main/scala/org/supler/field/Field.scala
Expand Up @@ -7,6 +7,7 @@ import org.supler.{FieldPath, MultiFieldRow, Row, RowsJSON}

trait Field[T] extends Row[T] {
def name: String
def label: Option[String]

private[supler] def enabledIf: T => Boolean
private[supler] def includeIf: T => Boolean
Expand All @@ -22,6 +23,7 @@ trait Field[T] extends Row[T] {
val fieldJson = JObject(
JField(JSONFieldNames.Name, JString(name)) ::
JField(JSONFieldNames.Enabled, JBool(isEnabled)) ::
JField(JSONFieldNames.Label, JString(label.getOrElse(""))) ::
fieldJsonPartial.obj)

RowsJSON.singleField(fieldJson, name)
Expand Down
Expand Up @@ -7,7 +7,6 @@ import org.supler._
trait GenerateBasicJSON[T] {
this: Field[T] =>

def label: Option[String]
def renderHint: Option[RenderHint]

private[supler] override def generateFieldJSON(parentPath: FieldPath, obj: T) = {
Expand All @@ -16,7 +15,6 @@ trait GenerateBasicJSON[T] {
import JSONFieldNames._

JObject(List(
JField(Label, JString(label.getOrElse(""))),
JField(Type, JString(data.fieldTypeName)),
JField(Validate, JObject(data.validationJSON.toList)),
JField(Path, JString(parentPath.append(name).toString))
Expand Down
6 changes: 3 additions & 3 deletions supler/src/main/scala/org/supler/field/SubformField.scala
Expand Up @@ -10,7 +10,7 @@ case class SubformField[T, ContU, U, Cont[_]](
name: String,
read: T => Cont[U],
write: (T, Cont[U]) => T,
_label: Option[String],
label: Option[String],
embeddedForm: Form[U],
// if not specified, `embeddedForm.createEmpty` will be used
createEmpty: Option[() => U],
Expand All @@ -20,7 +20,7 @@ case class SubformField[T, ContU, U, Cont[_]](

import c._

def label(newLabel: String): SubformField[T, ContU, U, Cont] = this.copy(_label = Some(newLabel))
def label(newLabel: String): SubformField[T, ContU, U, Cont] = this.copy(label = Some(newLabel))

def renderHint(newRenderHint: RenderHint with SubformFieldCompatible): SubformField[T, ContU, U, Cont] = this.copy(renderHint = newRenderHint)

Expand All @@ -37,7 +37,7 @@ case class SubformField[T, ContU, U, Cont[_]](
JField(Type, JString(SpecialFieldTypes.Subform)),
JField(RenderHint, JObject(JField("name", JString(renderHint.name)) :: renderHint.extraJSON)),
JField(Multiple, JBool(c.isMultiple)),
JField(Label, JString(_label.getOrElse(""))),
JField(Label, JString(label.getOrElse(""))),
JField(Path, JString(parentPath.append(name).toString)),
JField(Value, c.combineJValues(valuesAsJValue))
)
Expand Down

0 comments on commit 49fb1bf

Please sign in to comment.