Logging Hours of time spent watching movies.

classic Classic list List threaded Threaded
60 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Logging Hours of time spent watching movies.

aceospade
This is a reply to the previous thread about having a list of Star
Wars movies and being able to submit which was titled <xf:group>
inside an <xf:group>?. Now I still would like to know how to "log" how
many hours were used in a day and what movies were watched for what
period of time. The total hours in a day would have to equal the
broken down hours per movie. The movies would be in a select1 and then
there would be a button to add a movie and hours in which those would
be inputs. I wanted to add this in to the original form but was not
sure how to go about it. Any ideas or insight is greatly appreciated.
Don't worry about the previous thread(as I did not notice it until a
week later). Every little bit helps me to learn more.
Thank you again for all your help,
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

Aaron Reed
Hi Matthew,

If you have a list of movies an in each movie you know the title, the
characters, the actors, etc. AND the length of the movie, then it
shouldn't be too hard.  The user selects from the select1 that he
watched movie 'A'.  So you move into the 'watched movie instance
document' or 'watched movie node of the current instance document' the
movie information.  Then if you want to know how much movie time is in
the 'watched list', just use the xpath sum() function to add it up.  You
could kick off the sum() function by using @calculate on a xf:bind or
using xf:setvalue with @value containing the sum() function.

--Aaron


aceospade wrote:

> This is a reply to the previous thread about having a list of Star
> Wars movies and being able to submit which was titled <xf:group>
> inside an <xf:group>?. Now I still would like to know how to "log" how
> many hours were used in a day and what movies were watched for what
> period of time. The total hours in a day would have to equal the
> broken down hours per movie. The movies would be in a select1 and then
> there would be a button to add a movie and hours in which those would
> be inputs. I wanted to add this in to the original form but was not
> sure how to go about it. Any ideas or insight is greatly appreciated.
> Don't worry about the previous thread(as I did not notice it until a
> week later). Every little bit helps me to learn more.
> Thank you again for all your help,
> Matthew
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

aceospade
We know the length of the movies but we do not know if the whole movie
was watched or certain scenes. Say you have a select1 with the list of
movies and then two inputs that reference it. The first references the
movie selected and the second is where you would enter how many hours
that certain movie was watched. There would be a date, start, stop,
break and total time watched columns. You could pick the date from a
calender picker and say you started at 1 in the afternoon so it would
be 13 in the start, you watched until 9 that night so it would be 21
in the stop and a 30 minute break to get some snacks so in that column
it would be .50 there. So the total time watched category would tell
you that it was 7.5 hours. What I would like to see happen is you
could choose which hours to put with what movie even if the whole
movie wasn't watched. You could select the first movie, it would show
up in the input referenced to it but then you could designate how much
time of the alloted time was used for that particular movie. This
would be done for as many movies that were watched. If the total time
was 7.5 hours I would select one movie enter in 3.0 and then select
another movie and enter 2.5 then select a final movie and enter 2.0
(on a 2.5 hour movie) because I ran out of time. The  entered amount
of time would have to equal the total amount of time watched. If those
two amounts did not equal an alert message( incremental) and would
show up immediately. Thank you for taking the time. I hope this makes
a little more sense.
Have a good day,
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

aceospade
Is something like this even doable? I think I have a good idea on what
I want the form to do but I am not quite sure how to get it do to the
things inquired about. I am sorry if some of this is elementary. I
also appreciate all of you help thus far.
Thank you,
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

aceospade
I have gotten the form to work in the sense where you can add movies
or subtract the current movie. What I was wondering about was when you
mentioned the sum( ) function. How would you get the individual hours
to add up to the total hours would it be something like -
<xf:bind nodeset="/Time/TimeData/Allocated/Hours" calculate="sum(../
Hours)" />
I have the whole program if it helps any. Thank you for you thoughts
and I will continue to work on this.

Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

Aaron Reed
Hi Matthew,

Sorry I haven't replied more lately.  Pretty busy.

Yes, sum works over a nodeset.  But I assume what you want is to put the
sum in a single node.  So you should do something like:

<xf:bind nodeset="xpath expression of single node to store the sum total
in" calculate="sum(xpath expression that captures all of the nodes you
want to sum up)" />

--Aaron

aceospade wrote:

> I have gotten the form to work in the sense where you can add movies
> or subtract the current movie. What I was wondering about was when you
> mentioned the sum( ) function. How would you get the individual hours
> to add up to the total hours would it be something like -
> <xf:bind nodeset="/Time/TimeData/Allocated/Hours" calculate="sum(../
> Hours)" />
> I have the whole program if it helps any. Thank you for you thoughts
> and I will continue to work on this.
>
> Matthew
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

aceospade
No problem. Thank you for replying.
Something like...
<xf:bind nodeset="/Time/TimeData/TotalHours" calculate="sum(../
Hours)" />
and then reference that in an output somewhere? If I had this in a
repeat would that still work? How would I "refresh" the data set so it
could have new data on it?
Thanks again,
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

Aaron Reed
Hi Matthew,

That will work.  Then you'd just have <xf:output
ref="/Time/TimeData/TotalHours"/>.  The total will be automatically
recalculated whenever a xforms-recalculate or xf:recalculate happens on
the model that contains the bind.  For example, this will happen if a
control is bound to one of the Hours nodes and changes its value.  Also,
if more ../Hours nodes are added or some are removed from the instance
document (like via xf:copy or xf:insert), then a rebuild will happen
which means that a recalculate will happen and the TotalHours node will
be updated.

--Aaron

aceospade wrote:

> No problem. Thank you for replying.
> Something like...
> <xf:bind nodeset="/Time/TimeData/TotalHours" calculate="sum(../
> Hours)" />
> and then reference that in an output somewhere? If I had this in a
> repeat would that still work? How would I "refresh" the data set so it
> could have new data on it?
> Thanks again,
> Matthew
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

aceospade
I guess I'm not real sure what you mean. Would I be able to send you
the code so I can understand what goes where?
Thank you again for helping me.
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

Aaron Reed
Sure, send me the code

--Aaron

aceospade wrote:
> I guess I'm not real sure what you mean. Would I be able to send you
> the code so I can understand what goes where?
> Thank you again for helping me.
> Matthew
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

aceospade
This is what I have so far. What I was wondering was when the add
movie button is hit and you put in the number of hours watched for
that movie, how would you have those hours add up and print that total
out? An example would be to select a movie and enter 2 for the hours
the hit the button and select another movie and put 3 for the hours
the the total would equal 5. So far I haven't been able to get any
numbers to add up except for the begin, end and break times.

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:xf="http://www.w3.org/2002/xforms"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">

<head>

<title>Star Wars Movies</title>

        <style>
                .date .xf-value {width:70px;}
                .input .xf-value {width:38px;}
                html {overflow: -moz-scrollbars-vertical;}
        </style>

<xf:model id="MovieModel">
        <xf:instance>
                <Time xmlns="">
                        <TimeData>
                                <Movie />
                                <EntryDate />
                                <StartTime />
                                <StopTime />
                                <BreakTime />
                                <TotalEntryTime />
                                <TotalHours />
                                <Allocated>
                                        <Movie />
                                        <Hours />
                                </Allocated>
                                <Allocated>
                                        <Movie />
                                        <Hours />
                                </Allocated>
                        </TimeData>
                        <TimeData>
                                <Movie />
                                <EntryDate />
                                <StartTime />
                                <StopTime />
                                <BreakTime />
                                <TotalEntryTime />
                                <TotalHours />
                                <Allocated>
                                        <Movie />
                                        <Hours />
                                </Allocated>
                                <Allocated>
                                        <Movie />
                                        <Hours />
                                </Allocated>
                        </TimeData>
                </Time>
        </xf:instance>
        <xf:instance id="movies" xmlns="">
                <data>
                        <Movie>
                                <Title id="A New Hope" />
                                <Release>1977</Release>
                                <Director>George Lucas</Director>
                                <Episode>IV</Episode>
                                <Characters>Luke, Leia, Han, Chewbacca</Characters>
                        </Movie>
                        <Movie>
                                <Title id="Empire Strikes Back" />
                                <Release>1980</Release>
                                <Director>George Lucas</Director>
                                <Episode>V</Episode>
                                <Characters>Luke, Leia, Darth Vader, Lando</Characters>
                        </Movie>
                        <Movie>
                                <Title id="Return of the Jedi" />
                                <Release>1983</Release>
                                <Director>George Lucas</Director>
                                <Episode>VI</Episode>
                                <Characters>Luke, Boba Fett, Jabba the hutt</Characters>
                        </Movie>
                        <Movie>
                                <Title id="The Phantom Menace" />
                                <Release>1999</Release>
                                <Director>George Lucas</Director>
                                <Episode>I</Episode>
                                <Characters>Anakin, Qui-Gonn, Obi-Won</Characters>
                        </Movie>
                        <Movie>
                                <Title id="Attack of the Clones" />
                                <Release>2002</Release>
                                <Director>George Lucas</Director>
                                <Episode>II</Episode>
                                <Characters>Anakin, Obi-Won, Count Dooku</Characters>
                        </Movie>
                        <Movie>
                                <Title id="Revenge of the Sith" />
                                <Release>2005</Release>
                                <Director>George Lucas</Director>
                                <Episode>III</Episode>
                                <Characters>Anakin, Obi-Won, Mace Windu, Emperor Palpatine</
Characters>
                        </Movie>
                </data>
        </xf:instance>

        <xf:instance id="selected-movie" xmlns="">
                <movie-id xmlns="">A New Hope</movie-id>
        </xf:instance>

        <xf:instance id="selected" xmlns="">
                <movie-id xmlns="">Empire Strikes Back</movie-id>
        </xf:instance>

        <xf:bind nodeset="instance('movies')">
                <xf:bind nodeset="/data/Movie/Title" required="true( )" id="title" /
>
                <xf:bind nodeset="/data/Movie/Release" required="true( )"
id="release" />
                <xf:bind nodeset="/data/Movie/Director" required="true( )"
                        id="director" />
                <xf:bind nodeset="/data/Movie/Episode" required="true( )"
id="episode" />
                <xf:bind nodeset="/data/Movie/Characters" required="true( )"
                        id="characters" />
        </xf:bind>


                <xf:bind nodeset="/Time/TimeData/EntryDate" id="Date"
                        required="true(  )" type="xsd:date" />

                <xf:bind nodeset="/Time/TimeData/TotalEntryTime"
                        calculate="../StopTime - ../StartTime - ../BreakTime" />

                <xf:bind nodeset="/Time/TimeData/TotalHours" calculate="sum(/Time/
TimeData/Allocated/Hours)" />

          <xf:action ev:event="xforms-ready">
          <xf:setfocus control="movieEntry" />
      </xf:action>

      <xf:action ev:event="xforms-ready">
      <xf:rebuild model="MovieModel" />
  </xf:action>

        <xf:submission id="submit" ref="/Time" action="moviez.xml"
                replace="none" method="put" />

</xf:model>

</head>

<body>

<xf:select1 ref="instance('selected-movie')">
        <xf:label>
                <b>Film: </b>
        </xf:label>
        <xf:itemset nodeset="instance('movies')/Movie/Title/@id">
                <xf:label ref="." />
                <xf:value ref="." />
        </xf:itemset>
</xf:select1>

<xf:group
        ref="instance('movies')/Movie[Title/@id = instance('selected-
movie')]">
        <dl>
                <dt><b>Title: </b> <xf:output ref="Title/@id" /></dt>
                <dt><b>Release: </b> <xf:output ref="Release" /></dt>
                <dt><b>Director: </b> <xf:output ref="Director" /></dt>
                <dt><b>Episode: </b> <xf:output ref="Episode" /></dt>
                <dt><b>Characters: </b> <xf:output ref="Characters" /></dt>
        </dl>
</xf:group>

        <xf:trigger>
                <xf:label>
                        <b>Add an entry?</b>
                </xf:label>
                <xf:action ev:event="DOMActivate">
                        <xf:insert nodeset="TimeData" at="index('TimeData-repeat')"
position="after" />
                        <xf:setfocus control="TimeData-repeat" />
                        <xf:rebuild nodeset="TimeData" at="index('TimeData-repeat')" />
                </xf:action>
        </xf:trigger>

        <xf:trigger>
                <xf:label><b>Remove current entry?</b></xf:label>
                <xf:delete nodeset="TimeData[last()&gt;1]" at="index('TimeData-
repeat')" />
                <xf:insert nodeset="TimeData[last()=1]" at="index('TimeData-
repeat')" position="before" />
        </xf:trigger>
        <br />
        <br />
<xf:repeat nodeset="TimeData[position()!=last()]" id="TimeData-
repeat">
        <xf:label>Date: <xf:input ref="EntryDate" class="date" />&nbsp;</
xf:label>
        <xf:label>Begin: <xf:input ref="StartTime" class="input" /></
xf:label>
        <xf:label>End: <xf:input ref="StopTime" class="input" /></xf:label>
        <xf:label>Break: <xf:input ref="BreakTime" class="input" /></
xf:label>
        <xf:label>Total: <xf:input ref="TotalEntryTime" class="input" /></
xf:label>
        <xf:label>Total: <xf:input ref="TotalHours" class="input" /></
xf:label>

        <br />
        <br />
        <xf:select1 ref="instance('selected')">
                <xf:label>
                        <b>Film: </b>
                </xf:label>
                <xf:itemset nodeset="instance('movies')/Movie/Title/@id">
                        <xf:label ref="." />
                        <xf:value ref="." />
                </xf:itemset>
        </xf:select1>
&nbsp; &nbsp;
        <xf:trigger>
                <xf:label>Add Movie</xf:label>
                <xf:action ev:event="DOMActivate">
                        <xf:insert nodeset="Allocated[position()=index('newmovies-list')]"
                                at="index('newmovies-list')" />
                        <xf:setvalue ref="Allocated[index('newmovies-list')]/Movie"
                                value="instance('movies')/Movie[Title/@id = instance('selected')]/
Title/@id" />
                        <xf:setfocus control="movieEntry" />
            <xf:rebuild/>
            <xf:refresh/>
                </xf:action>
        </xf:trigger>

        <xf:trigger>
                <xf:label>Delete Movie</xf:label>
                <xf:action ev:event="DOMActivate">
                        <xf:delete nodeset="Allocated[last()&gt;1]"
                                at="index('newmovies-list')" />
                        <xf:insert nodeset="Allocated[last()=1]" at="index('newmovies-
list')"
                                position="after" />
                </xf:action>
        </xf:trigger>
        <xf:trigger>
                <xf:label>Recalculate</xf:label>
                <xf:action ev:event="DOMActivate">
                        <xf:recalculate  model="MovieModel" nodeset="/Time/TimeData/
Allocated/Hours" ref="TotalHours" />
                </xf:action>
        </xf:trigger>

        <br />
        <br />

        <xf:repeat id="newmovies-list" nodeset="Allocated[position()!
=last()]">
                <xf:label>Movie: <xf:input ref="Movie" id="movieEntry" />
                </xf:label>
                <xf:label>Hours: <xf:input ref="Hours" />
                </xf:label>
        </xf:repeat>
        <br />
</xf:repeat>

<xf:submit submission="submit">
        <xf:label> Save </xf:label>
</xf:submit>

</body>
</html>

I have other questions that I still am not sure about but the hours is
what is troubling me at the time.
Thanks again,
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Logging Hours of time spent watching movies.

Clark, John
Matthew,

Thanks for posting a complete example.  I haven't had a complete chance
to fully digest your form, but one change that I had to make was to go
from expressions like "/Time/TimeData/TotalHours" to
"TimeData/TotalHours", since by default the context for expressions is
the root element (*not* the root node) of the default instance.  I still
have to do more tweaking before I can get the form to fully work,
though.

Take care,

    John L. Clark

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf
> Of aceospade
> Sent: Monday, September 10, 2007 9:49 AM
> To: [hidden email]
> Subject: Re: Logging Hours of time spent watching movies.
>
> This is what I have so far. What I was wondering was when the
> add movie button is hit and you put in the number of hours
> watched for that movie, how would you have those hours add up
> and print that total out? An example would be to select a
> movie and enter 2 for the hours the hit the button and select
> another movie and put 3 for the hours the the total would
> equal 5. So far I haven't been able to get any numbers to add
> up except for the begin, end and break times.
>
> <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE html
> PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:ev="http://www.w3.org/2001/xml-events"
> xmlns:xforms="http://www.w3.org/2002/xforms"
> xmlns:xf="http://www.w3.org/2002/xforms"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <head>
>
> <title>Star Wars Movies</title>
>
>         <style>
> .date .xf-value {width:70px;}
> .input .xf-value {width:38px;}
> html {overflow: -moz-scrollbars-vertical;}
> </style>
>
> <xf:model id="MovieModel">
> <xf:instance>
> <Time xmlns="">
> <TimeData>
> <Movie />
> <EntryDate />
> <StartTime />
> <StopTime />
> <BreakTime />
> <TotalEntryTime />
> <TotalHours />
> <Allocated>
> <Movie />
> <Hours />
> </Allocated>
> <Allocated>
> <Movie />
> <Hours />
> </Allocated>
> </TimeData>
> <TimeData>
> <Movie />
> <EntryDate />
> <StartTime />
> <StopTime />
> <BreakTime />
> <TotalEntryTime />
> <TotalHours />
> <Allocated>
> <Movie />
> <Hours />
> </Allocated>
> <Allocated>
> <Movie />
> <Hours />
> </Allocated>
> </TimeData>
> </Time>
> </xf:instance>
> <xf:instance id="movies" xmlns="">
> <data>
> <Movie>
> <Title id="A New Hope" />
> <Release>1977</Release>
> <Director>George Lucas</Director>
> <Episode>IV</Episode>
> <Characters>Luke, Leia, Han,
> Chewbacca</Characters>
> </Movie>
> <Movie>
> <Title id="Empire Strikes Back" />
> <Release>1980</Release>
> <Director>George Lucas</Director>
> <Episode>V</Episode>
> <Characters>Luke, Leia, Darth
> Vader, Lando</Characters>
> </Movie>
> <Movie>
> <Title id="Return of the Jedi" />
> <Release>1983</Release>
> <Director>George Lucas</Director>
> <Episode>VI</Episode>
> <Characters>Luke, Boba Fett,
> Jabba the hutt</Characters>
> </Movie>
> <Movie>
> <Title id="The Phantom Menace" />
> <Release>1999</Release>
> <Director>George Lucas</Director>
> <Episode>I</Episode>
> <Characters>Anakin, Qui-Gonn,
> Obi-Won</Characters>
> </Movie>
> <Movie>
> <Title id="Attack of the Clones" />
> <Release>2002</Release>
> <Director>George Lucas</Director>
> <Episode>II</Episode>
> <Characters>Anakin, Obi-Won,
> Count Dooku</Characters>
> </Movie>
> <Movie>
> <Title id="Revenge of the Sith" />
> <Release>2005</Release>
> <Director>George Lucas</Director>
> <Episode>III</Episode>
> <Characters>Anakin, Obi-Won,
> Mace Windu, Emperor Palpatine</
> Characters>
> </Movie>
> </data>
> </xf:instance>
>
> <xf:instance id="selected-movie" xmlns="">
> <movie-id xmlns="">A New Hope</movie-id>
> </xf:instance>
>
> <xf:instance id="selected" xmlns="">
> <movie-id xmlns="">Empire Strikes Back</movie-id>
> </xf:instance>
>
> <xf:bind nodeset="instance('movies')">
> <xf:bind nodeset="/data/Movie/Title"
> required="true( )" id="title" /
> >
> <xf:bind nodeset="/data/Movie/Release"
> required="true( )"
> id="release" />
> <xf:bind nodeset="/data/Movie/Director"
> required="true( )"
> id="director" />
> <xf:bind nodeset="/data/Movie/Episode"
> required="true( )"
> id="episode" />
> <xf:bind nodeset="/data/Movie/Characters"
> required="true( )"
> id="characters" />
> </xf:bind>
>
>
> <xf:bind nodeset="/Time/TimeData/EntryDate" id="Date"
> required="true(  )" type="xsd:date" />
>
> <xf:bind nodeset="/Time/TimeData/TotalEntryTime"
> calculate="../StopTime - ../StartTime -
> ../BreakTime" />
>
> <xf:bind nodeset="/Time/TimeData/TotalHours"
> calculate="sum(/Time/ TimeData/Allocated/Hours)" />
>
>  <xf:action ev:event="xforms-ready">
>           <xf:setfocus control="movieEntry" />
>       </xf:action>
>
>       <xf:action ev:event="xforms-ready">
>       <xf:rebuild model="MovieModel" />
>   </xf:action>
>
> <xf:submission id="submit" ref="/Time" action="moviez.xml"
> replace="none" method="put" />
>
> </xf:model>
>
> </head>
>
> <body>
>
> <xf:select1 ref="instance('selected-movie')">
> <xf:label>
> <b>Film: </b>
> </xf:label>
> <xf:itemset nodeset="instance('movies')/Movie/Title/@id">
> <xf:label ref="." />
> <xf:value ref="." />
> </xf:itemset>
> </xf:select1>
>
> <xf:group
> ref="instance('movies')/Movie[Title/@id =
> instance('selected- movie')]">
> <dl>
> <dt><b>Title: </b> <xf:output ref="Title/@id" /></dt>
> <dt><b>Release: </b> <xf:output ref="Release" /></dt>
> <dt><b>Director: </b> <xf:output ref="Director" /></dt>
> <dt><b>Episode: </b> <xf:output ref="Episode" /></dt>
> <dt><b>Characters: </b> <xf:output
> ref="Characters" /></dt>
> </dl>
> </xf:group>
>
> <xf:trigger>
> <xf:label>
> <b>Add an entry?</b>
> </xf:label>
> <xf:action ev:event="DOMActivate">
> <xf:insert nodeset="TimeData"
> at="index('TimeData-repeat')"
> position="after" />
> <xf:setfocus control="TimeData-repeat" />
> <xf:rebuild nodeset="TimeData"
> at="index('TimeData-repeat')" />
> </xf:action>
> </xf:trigger>
>
> <xf:trigger>
> <xf:label><b>Remove current entry?</b></xf:label>
> <xf:delete nodeset="TimeData[last()&gt;1]"
> at="index('TimeData- repeat')" />
> <xf:insert nodeset="TimeData[last()=1]"
> at="index('TimeData- repeat')" position="before" />
> </xf:trigger>
> <br />
> <br />
> <xf:repeat nodeset="TimeData[position()!=last()]"
> id="TimeData- repeat">
> <xf:label>Date: <xf:input ref="EntryDate" class="date"
> />&nbsp;</ xf:label>
> <xf:label>Begin: <xf:input ref="StartTime"
> class="input" /></ xf:label>
> <xf:label>End: <xf:input ref="StopTime" class="input"
> /></xf:label>
> <xf:label>Break: <xf:input ref="BreakTime"
> class="input" /></ xf:label>
> <xf:label>Total: <xf:input ref="TotalEntryTime"
> class="input" /></ xf:label>
> <xf:label>Total: <xf:input ref="TotalHours"
> class="input" /></ xf:label>
>
> <br />
> <br />
> <xf:select1 ref="instance('selected')">
> <xf:label>
> <b>Film: </b>
> </xf:label>
> <xf:itemset
> nodeset="instance('movies')/Movie/Title/@id">
> <xf:label ref="." />
> <xf:value ref="." />
> </xf:itemset>
> </xf:select1>
> &nbsp; &nbsp;
> <xf:trigger>
> <xf:label>Add Movie</xf:label>
> <xf:action ev:event="DOMActivate">
> <xf:insert
> nodeset="Allocated[position()=index('newmovies-list')]"
> at="index('newmovies-list')" />
> <xf:setvalue
> ref="Allocated[index('newmovies-list')]/Movie"
>
> value="instance('movies')/Movie[Title/@id =
> instance('selected')]/ Title/@id" />
> <xf:setfocus control="movieEntry" />
>             <xf:rebuild/>
>             <xf:refresh/>
> </xf:action>
> </xf:trigger>
>
> <xf:trigger>
> <xf:label>Delete Movie</xf:label>
> <xf:action ev:event="DOMActivate">
> <xf:delete nodeset="Allocated[last()&gt;1]"
> at="index('newmovies-list')" />
> <xf:insert
> nodeset="Allocated[last()=1]" at="index('newmovies- list')"
> position="after" />
> </xf:action>
> </xf:trigger>
> <xf:trigger>
> <xf:label>Recalculate</xf:label>
> <xf:action ev:event="DOMActivate">
> <xf:recalculate  model="MovieModel"
> nodeset="/Time/TimeData/ Allocated/Hours" ref="TotalHours" />
> </xf:action>
> </xf:trigger>
>
> <br />
> <br />
>
> <xf:repeat id="newmovies-list" nodeset="Allocated[position()!
> =last()]">
> <xf:label>Movie: <xf:input ref="Movie"
> id="movieEntry" />
> </xf:label>
> <xf:label>Hours: <xf:input ref="Hours" />
> </xf:label>
> </xf:repeat>
> <br />
> </xf:repeat>
>
> <xf:submit submission="submit">
> <xf:label> Save </xf:label>
> </xf:submit>
>
> </body>
> </html>
>
> I have other questions that I still am not sure about but the
> hours is what is troubling me at the time.
> Thanks again,
> Matthew
>
> _______________________________________________
> dev-tech-xforms mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-xforms
>
>

===================================

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2007).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.



_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

aceospade
In reply to this post by aceospade
Thanks for the insight about the root node. What I thought was you had
to distinctly lay out each node to not confuse the form. One thing I
noticed after I posted the code was that the remove entry wasn't
working. I made some changes and for the remove button to work it
should be

<xf:trigger>
        <xf:label><b>Remove current entry?</b></xf:label>
        <xf:delete ev:event="DOMActivate" nodeset="TimeData[last()&gt;1]"
at="index('TimeData-repeat')" />
        <xf:insert ev:event="DOMActivate" nodeset="TimeData[last()=1]"
at="index('TimeData-repeat')" position="before" />
</xf:trigger>

instead of what was posted. Sorry about that.
Thank you for taking the time.
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Logging Hours of time spent watching movies.

Clark, John
Matthew,

So... the advice that I posted previously was blatantly wrong.
Harmless, but wrong.  Both of these expressions will select the same
node-set: "/Time/TimeData/TotalHours" and "TimeData/TotalHours".  I'm
sorry about that.  An instance has a root node, and your original
expressions start from the root node of the default instance, so they're
just fine.

Now, to calculate the sum of the total hours, I had to tweak your XPath
expression slightly.  Here is the result:

  <xf:bind nodeset="/Time/TimeData/TotalHours"
           calculate="sum(../Allocated[string(Movie)]/Hours)" />

Note the relative path for the `calculate` attribute; this is necessary
to only take the sum over `Hours` elements that are descendants of the
current `TimeData` element (which I believe is what is desired).  The
reason for the `string(Movie)` predicate is to only take the sum over
those `Allocated` elements that actually have a movie specified; this is
important because you use two `Allocated` elements as templates.  You
might want to move these template elements to a separate instance so
they don't get in the way of your "good" data.  Let us know if you'd
like help with that refactoring, or if you have any other questions; I'd
be happy to contribute.

Now we just need a comprehensive list of movie metadata in XML format on
the Web, and we're good to go!

> Thanks for the insight about the root node. What I thought
> was you had to distinctly lay out each node to not confuse
> the form. One thing I noticed after I posted the code was
> that the remove entry wasn't working. I made some changes and
> for the remove button to work it should be
>
> <xf:trigger>
>         <xf:label><b>Remove current entry?</b></xf:label>
> <xf:delete ev:event="DOMActivate"
> nodeset="TimeData[last()&gt;1]"
> at="index('TimeData-repeat')" />
> <xf:insert ev:event="DOMActivate" nodeset="TimeData[last()=1]"
> at="index('TimeData-repeat')" position="before" /> </xf:trigger>

As you've noticed, the problem here was that you hadn't attached your
actions to events (in this case, the "DOMActivate" event, which is quite
common).  If you want to control the order in which these actions take
place, you might want to group them under a common `xf:action` action.
For example:

  <xf:action ev:event="DOMActivate">
    <xf:delete nodeset="TimeData[last()&gt;1]"
at="index('TimeData-repeat')" />
    <xf:insert nodeset="TimeData[last()=1]"
at="index('TimeData-repeat')" position="before" />
  </xf:action>

That way, when a "DOMActivate" event happens (that is, when you click
the button), the delete will always happen first, and the insert will
happen second.

Take care,

    John L. Clark

===================================

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2007).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.



_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Logging Hours of time spent watching movies.

Clark, John
I almost forgot, I had to make one other change to your form.  In order
to cause the field displaying the sum to be updated, I had to add an
`xf:refresh` action to your "Recalculate" trigger:

  <xf:trigger>
    <xf:label>Recalculate</xf:label>
    <xf:action ev:event="DOMActivate">
      <xf:recalculate/>
      <xf:refresh/>
    </xf:action>
  </xf:trigger>

An alternative to this trigger would be to set up an action that listens
for the `xforms-value-changed` event on one of the "Hours" fields, and
calls the `xf:recalculate` and `xf:refresh` actions at that time.

Take care,

    John L. Clark

===================================

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2007).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.



_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

aceospade
In reply to this post by Clark, John
Yes! That is exactly what I was wanting to happen! How would I get the
Allocated/Hours to equal the TotalEntryTime? Where if the two did not
match up an error would be displayed and you could not submit.
Speaking of submitting...that in my opinion is one of the last steps
remaining. This has gotten farther than what I expected and I am very
grateful for all of your help. The next thing would be to make sure
the two Total hours columns were equal and print out an error if they
were not. I am guessing that there would have to be a bind on each of
the times and then gave it the properties that must be equal and if
not then an error message would be displayed. Is this on the right
track?
Thank you again,
Matthew

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Logging Hours of time spent watching movies.

Clark, John
Matthew,

> Yes! That is exactly what I was wanting to happen! How would
> I get the Allocated/Hours to equal the TotalEntryTime? Where
> if the two did not match up an error would be displayed and
> you could not submit.

One fun way to do this is to take advantage of the interaction between
validity model item properties and CSS.  To begin, we create a container
for our error message within the "TimeData-repeat" `xf:repeat` element:

  <xf:group ref="TotalEntryTime" class="errorReport">
    <p>Your times don't add up!</p>
  </xf:group>

Since this group is bound to `TotalEntryTime`, it will "know about" the
model item properties attached to that element.  In particular, we can
indicate that the total entry time should be invalid whenever it doesn't
match the sum that we calculated:

  <xf:bind nodeset="/Time/TimeData/TotalEntryTime"
    constraint=". = ../TotalHours" />

Finally, we need to style the group based upon whether `TotalEntryTime`
is valid or not.  If it's valid, we want to hide the error message,
otherwise we can show and highlight the error message.  Like so (in your
`style` element):

  .errorReport:invalid { display: block; color: red; }
  .errorReport:valid { display: none; }

Now, if you enter a date, a start of 14 (for 2 in the afternoon), a end
of 19, a break of 1, then add two movies that each are 2 hours long, the
message should disapear.  Change the break to 1.5, and the message
reappears.  This is somewhat crude, and can be refined quite a bit
through more sophisticated form engineering.

I'll get to submitting in my next response.

Take care,

    John L. Clark

===================================

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2007).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.



_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Logging Hours of time spent watching movies.

aceospade
In reply to this post by aceospade
One other thing just occurred to me. When the page is refreshed there
is one entry listed. When you start to enter data into that entry and
hit the repeat button you can add movie movies/hours on the new entry
but if you try to go back to the original entry and enter another
movie it does not allow you to do anything to it except delete the
first movie. Does any one have any idea why this is? But when you
refresh the page and put 3 entries on the page you can go back and
forth between all three. You can add movies, delete movies and delete
which ever entry the cursor is in. This does not really make any sense
as to why this happens. Any ideas?

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Logging Hours of time spent watching movies.

Clark, John
In reply to this post by aceospade
> Speaking of submitting...that in my opinion is one of the
> last steps remaining.

Indeed.  If you are using Firefox (and you are, right?  ;-), the error
console (under the Tools menu) is one very useful tool for debugging,
and I found it handy in this case.  After some hacking, I ran into the
message:

Warning: XForms Warning (5): Submission validation failed for node
Source Code:
<EntryDate/>

which caused me to notice that you assert that `EntryDate` must have
type `xsd:date`, but you always leave a single "template" `TimeData`
element as the last child of the `Time` element, which will always have
an empty `EntryDate` child.  As I mentioned earlier, one way to deal
with this would be to move your templates into a separate instance.
Alternatively, we can solve this problem directly; in this case, we only
really want to validate the content of all but the last `TimeData`
elements.  This requires the following two `xf:bind` elements in place
of the ones you had previously:

  <xf:bind nodeset="/Time/TimeData[position() &lt; last()]/EntryDate"
    required="true()" type="xsd:date" />

  <xf:bind nodeset="/Time/TimeData[position() &lt;
last()]/TotalEntryTime"
    constraint=". = ../TotalHours" />

Now the data saves just fine (once it's valid).

Take care,

    John L. Clark

===================================

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2007).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.



_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Logging Hours of time spent watching movies.

Clark, John
In reply to this post by aceospade
> One other thing just occurred to me. When the page is
> refreshed there is one entry listed. When you start to enter
> data into that entry and hit the repeat button you can add
> movie movies/hours on the new entry but if you try to go back
> to the original entry and enter another movie it does not
> allow you to do anything to it except delete the first movie.

What "repeat" button do you mean?  The trigger to "Add an entry?" or the
trigger to "Add Movie"?  If I "Add Movie", I can change the hours for
any movie that I've added.  If I "Add an entry?", I can change hours for
any of the entries.

Take care,

    John L. Clark

===================================

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2007).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.



_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
123