Skip to content

Commit

Permalink
Discussion: gray out 'post' button when message is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
achlipala committed Nov 1, 2015
1 parent b1a4b9d commit b82fc7a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
4 changes: 3 additions & 1 deletion ckeditor.ur
Expand Up @@ -19,4 +19,6 @@ fun show ed = ed.Show

fun content ed = signal ed.Source

fun setContent ed s = CkeditorFfi.setContent ed.Id s
fun setContent ed s =
set ed.Source s;
CkeditorFfi.setContent ed.Id s
20 changes: 11 additions & 9 deletions discussion.ur
Expand Up @@ -22,13 +22,11 @@ functor Make(M : sig
val fl : folder key
val kinj : $(map sql_injectable key)

type text
type text_internal
type text_config
val text : Widget.t text text_internal text_config
val inj : sql_injectable text
val text : Widget.t string text_internal text_config

table message : (key ++ [Thread = time, When = time, Who = string, Text = text])
table message : (key ++ [Thread = time, When = time, Who = string, Text = string])

val access : $key -> transaction access
end) = struct
Expand All @@ -39,7 +37,7 @@ functor Make(M : sig

type message = {When : time,
Who : string,
Text : text}
Text : string}

datatype messages =
Nil
Expand All @@ -56,8 +54,8 @@ functor Make(M : sig

datatype update =
NewThread of { Thread : time, Subject : string }
| New of { Thread : time, When : time, Who : string, Text : text }
| Edit of { Thread: time, When : time, Text : text }
| New of { Thread : time, When : time, Who : string, Text : string }
| Edit of { Thread: time, When : time, Text : string }
| Delete of { Thread : time, When : time }

type a = {Config : text_config,
Expand Down Expand Up @@ -312,6 +310,7 @@ functor Make(M : sig
</div>

{renderPosts ls'}

</xml>)}/>
</xml>

Expand Down Expand Up @@ -372,9 +371,12 @@ functor Make(M : sig
| Some u => <xml>
<h2>Post Message</h2>

{@Widget.asWidget text a.NewPost None}
{@Widget.asWidget text a.NewPost None}<br/>

<button class="btn btn-primary"
<button dynClass={v <- @Widget.value text a.NewPost;
return (case v of
"" => CLASS "btn disabled"
| _ => CLASS "btn btn-primary")}
value="Post"
onclick={fn _ =>
txt <- current (@Widget.value text a.NewPost);
Expand Down
6 changes: 2 additions & 4 deletions discussion.urs
Expand Up @@ -21,13 +21,11 @@ functor Make(M : sig
val fl : folder key
val kinj : $(map sql_injectable key)

type text
type text_internal
type text_config
val text : Widget.t text text_internal text_config
val inj : sql_injectable text
val text : Widget.t string text_internal text_config

table message : (key ++ [Thread = time, When = time, Who = string, Text = text])
table message : (key ++ [Thread = time, When = time, Who = string, Text = string])

val access : $key -> transaction access
end) : Ui.S where type input = $M.key
6 changes: 2 additions & 4 deletions tableDiscussion.ur
Expand Up @@ -14,18 +14,16 @@ functor Make(M : sig
constraint [keyName] ~ otherConstraints
val parent : sql_table (key ++ rest) ([keyName = map (fn _ => ()) key] ++ otherConstraints)

type text
type text_internal
type text_config
val text : Widget.t text text_internal text_config
val inj : sql_injectable text
val text : Widget.t string text_internal text_config

val access : $key -> transaction Discussion.access
end) = struct

open M

table message : (key ++ [Thread = time, When = time, Who = string, Text = text])
table message : (key ++ [Thread = time, When = time, Who = string, Text = string])
PRIMARY KEY {{@primary_key [key1] [keyR ++ [Thread = _, When = _]] ! !
(kinj ++ _)}},
{{one_constraint [#Parent] (@Sql.easy_foreign ! ! ! ! ! ! fl parent)}}
Expand Down
4 changes: 1 addition & 3 deletions tableDiscussion.urs
Expand Up @@ -16,11 +16,9 @@ functor Make(M : sig
constraint [keyName] ~ otherConstraints
val parent : sql_table (key ++ rest) ([keyName = map (fn _ => ()) key] ++ otherConstraints)

type text
type text_internal
type text_config
val text : Widget.t text text_internal text_config
val inj : sql_injectable text
val text : Widget.t string text_internal text_config

val access : $key -> transaction Discussion.access
end) : Ui.S where type input = $M.key

0 comments on commit b82fc7a

Please sign in to comment.