fix 11432 DataTable date input
This commit is contained in:
parent
731ae3801a
commit
625da8bb41
4 changed files with 39 additions and 1 deletions
|
|
@ -10,6 +10,7 @@
|
|||
- fixed #11758: formatting on account stuff is wrong
|
||||
- fixed #11770: Starter needs to set all account plugins
|
||||
- fixed #11771: Default Newsletter template not set
|
||||
- fixed #11432: DataTable date input
|
||||
|
||||
7.9.10
|
||||
- fixed #11721: spamStopWords not in WebGUI.conf.original
|
||||
|
|
|
|||
|
|
@ -142,6 +142,26 @@ sub getDataTemplateVars {
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getDateFormat ( )
|
||||
|
||||
Get the current date format for the current user in a strftime format that YUI can
|
||||
understand.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDateFormat {
|
||||
my ( $self ) = @_;
|
||||
|
||||
my $dateFormat
|
||||
= WebGUI::DateTime->new( $self->session )->webguiToStrftime( $self->session->user->get('dateFormat') );
|
||||
# Special handle %_varmonth_ super special WebGUI field that strftime doesn't have
|
||||
$dateFormat =~ s/%_varmonth_/%m/g;
|
||||
|
||||
return $dateFormat;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 getEditForm ( )
|
||||
|
||||
Add the data table to the edit form.
|
||||
|
|
@ -161,6 +181,7 @@ sub getEditForm {
|
|||
value => $self->get("data"),
|
||||
defaultValue => undef,
|
||||
showEdit => 1,
|
||||
dateFormat => $self->getDateFormat,
|
||||
}
|
||||
)->toHtml
|
||||
. q{</td></tr>}
|
||||
|
|
@ -225,6 +246,7 @@ sub prepareView {
|
|||
name => $self->getId,
|
||||
value => $self->get('data'),
|
||||
defaultValue => undef,
|
||||
dateFormat => $self->getDateFormat,
|
||||
}
|
||||
);
|
||||
$dt->prepare;
|
||||
|
|
|
|||
|
|
@ -68,6 +68,10 @@ Any extra name=value pairs needed to save the data successfully
|
|||
If true, will enable the table for editing. This is only necessary when
|
||||
displaying the table with getValueAsHtml().
|
||||
|
||||
=head4 dateFormat
|
||||
|
||||
A strftime string describing the proper date format
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
|
|
@ -81,6 +85,7 @@ sub definition {
|
|||
ajaxSaveUrl => { defaultValue => undef, },
|
||||
ajaxSaveFunc => { defaultValue => "view", },
|
||||
ajaxSaveExtras => { defaultValue => undef, },
|
||||
dateFormat => { defaultValue => '%y-%m-%d', },
|
||||
};
|
||||
|
||||
return $class->SUPER::definition( $session, $definition );
|
||||
|
|
@ -116,6 +121,8 @@ sub getDataTableHtml {
|
|||
textbox => "textbox",
|
||||
);
|
||||
|
||||
my $dateFormat = $self->get('dateFormat') || '%y-%m-%d';
|
||||
|
||||
my @columnsJson = ();
|
||||
for my $column ( @{ $data->{columns} } ) {
|
||||
|
||||
|
|
@ -125,6 +132,7 @@ sub getDataTableHtml {
|
|||
. qq["key" : "$column->{ key }", ]
|
||||
. qq["abbr" : "$column->{ key }", ]
|
||||
. qq["formatter" : "$column->{ formatter }", ]
|
||||
. ( $column->{formatter} eq "Date" ? qq["dateOptions" : { "format" : "$dateFormat" },] : "" )
|
||||
. qq["resizable" : 1, ]
|
||||
. qq["sortable" : 1];
|
||||
|
||||
|
|
@ -155,6 +163,7 @@ sub getDataTableHtml {
|
|||
"ajaxDataFunc" => $self->get('ajaxDataFunc'),
|
||||
"ajaxSaveUrl" => $self->get('ajaxSaveUrl'),
|
||||
"ajaxSaveFunc" => $self->get('ajaxSaveFunc'),
|
||||
"dateFormat" => $dateFormat,
|
||||
};
|
||||
my $optionsJson = JSON->new->encode($options);
|
||||
|
||||
|
|
|
|||
|
|
@ -202,7 +202,10 @@ WebGUI.Form.DataTable
|
|||
YAHOO.util.Dom.get( this.containerId + "-table" ).style.display = "none";
|
||||
}
|
||||
|
||||
var dataTableOptions = { };
|
||||
var dataTableOptions = {
|
||||
dateOptions : { format : this.options.dateFormat }
|
||||
};
|
||||
|
||||
if ( this.options.showEdit ) {
|
||||
dataTableOptions.draggableColumns = true;
|
||||
}
|
||||
|
|
@ -629,6 +632,9 @@ WebGUI.Form.DataTable
|
|||
sortable : ( col ? col.sortable : 1 ),
|
||||
editor : ( format == "date" ? "date" : "textbox")
|
||||
};
|
||||
if ( format == "date" ) {
|
||||
newCol["dateOptions"] = { format : this.options.dateFormat };
|
||||
}
|
||||
var newIndex = col ? col.getKeyIndex() : undefined;
|
||||
|
||||
this.dataTable.insertColumn( newCol, newIndex );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue