Ignore:
Timestamp:
Dec 20, 2011, 9:37:35 AM (13 years ago)
Author:
chronos
Message:
  • Opraveno: Generování výstupu u TQueryForm a THtmlTable.
  • Přidáno: Mimo přihlašovací formulář přidán také registrační.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UWebObjects.pas

    r65 r66  
    3838    Title: string;
    3939    Rows: TListObject; // TListObject<TQueryFormItem>
     40    function AddNewItem: TQueryFormItem;
    4041    constructor Create;
    4142    destructor Destroy; override;
    4243  end;
    4344
     45  TQueryAction = class
     46    Name: string;
     47  end;
     48
    4449  TQueryForm = class(THtmlForm)
    45   private
     50  protected
     51    function GetAsXmlElement: TXmlElement; override;
    4652  public
    4753    Title: string;
    4854    Groups: TListObject; // TListObject<TQueryFormGroup>
    49     Actions: TListObject; // TListObject<THtmlInput>
    50     function GetAsXmlElement: TXmlElement; override;
     55    Actions: TListObject; // TListObject<TQueryAction>
     56    ClassId: string;
     57    function AddNewGroup: TQueryFormGroup;
     58    function AddNewAction: TQueryAction;
    5159    constructor Create;
    5260    destructor Destroy; override;
     
    9098  I: Integer;
    9199  G: Integer;
     100  Table: THtmlTable;
     101  Row: THtmlRow;
    92102begin
    93103  Result := inherited GetAsXmlElement;
    94104  with TXmlTag(Result).SubElements do begin
     105    Table := THtmlTable.Create;
     106    Table.ClassId := ClassId;
     107    Row := THtmlRow(Table.Rows.AddNew(THtmlRow.Create));
     108    with THtmlCell(Row.Cells.AddNew(THtmlCell.Create)) do begin
     109      ColSpan := 2;
     110      Value := THtmlString.Create;
     111      THtmlString(Value).Text := Title;
     112    end;
     113    with Table do
    95114    for G := 0 to Groups.Count - 1 do
    96115    with TQueryFormGroup(Groups[G]) do begin
    97       with TXmlString(AddNew(TXmlString.Create)) do begin
    98         Text := Title;
    99       end;
    100       with THtmlLineBreak.Create do begin
    101         Add(AsXmlElement);
     116      if Title <> '' then begin
     117        Row := THtmlRow(Table.Rows.AddNew(THtmlRow.Create));
     118        with THtmlCell(Row.Cells.AddNew(THtmlCell.Create)) do begin
     119          ColSpan := 2;
     120          Value := THtmlString.Create;
     121          THtmlString(Value).Text := Title;
     122        end;
    102123      end;
    103124      for I := 0 to Rows.Count - 1 do
    104125      with TQueryFormItem(Rows[I]) do begin
    105         with TXmlString(AddNew(TXmlString.Create)) do begin
    106           Text := Caption + ': ';
     126        Row := THtmlRow(Table.Rows.AddNew(THtmlRow.Create));
     127        with THtmlCell(Row.Cells.AddNew(THtmlCell.Create)) do begin
     128          Value := THtmlString.Create;
     129          THtmlString(Value).Text := Caption + ': ';
    107130        end;
    108         Add(Value.AsXmlElement);
    109         with THtmlLineBreak.Create do begin
    110           Add(AsXmlElement);
     131        with THtmlCell(Row.Cells.AddNew(THtmlCell.Create)) do begin
     132          Value := THtmlInput.Create;
     133          Value.Assign(TQueryFormItem(Rows[I]).Value);
    111134        end;
    112135      end;
    113136    end;
    114     with THtmlInput.Create do begin
    115       Value := 'Přihlásit';
    116       InputType := itSubmit;
    117       Add(AsXmlElement);
     137    Row := THtmlRow(Table.Rows.AddNew(THtmlRow.Create));
     138    with THtmlCell(Row.Cells.AddNew(THtmlCell.Create)) do begin
     139      ColSpan := 2;
     140      for I := 0 to Actions.Count - 1 do
     141      Value := THtmlBlock.Create;
     142      with THtmlInput(THtmlBlock(Value).SubItems.AddNew(THtmlInput.Create)) do begin
     143        Value := TQueryAction(Actions[I]).Name;
     144        InputType := itSubmit;
     145      end;
    118146    end;
     147    Add(Table.AsXmlElement);
     148    Table.Free;
    119149  end;
     150end;
     151
     152function TQueryForm.AddNewGroup: TQueryFormGroup;
     153begin
     154  Result := TQueryFormGroup(Groups.AddNew(TQueryFormGroup.Create));
     155end;
     156
     157function TQueryForm.AddNewAction: TQueryAction;
     158begin
     159  Result := TQueryAction(Actions.AddNew(TQueryAction.Create));
    120160end;
    121161
     
    125165  Actions := TListObject.Create;
    126166  Groups := TListObject.Create;
     167  Method := 'post';
    127168end;
    128169
     
    135176
    136177{ TQueryFormGroup }
     178
     179function TQueryFormGroup.AddNewItem: TQueryFormItem;
     180begin
     181  Result := TQueryFormItem(Rows.AddNew(TQueryFormItem.Create));
     182end;
    137183
    138184constructor TQueryFormGroup.Create;
Note: See TracChangeset for help on using the changeset viewer.