ソースを参照

* Added property CurrentAction

git-svn-id: trunk@9263 -
joost 17 年 前
コミット
807a18e109
2 ファイル変更67 行追加4 行削除
  1. 60 4
      packages/fcl-web/src/fpdatasetform.pp
  2. 7 0
      packages/fcl-web/src/fpweb.pp

+ 60 - 4
packages/fcl-web/src/fpdatasetform.pp

@@ -76,7 +76,8 @@ type
     FLabelPos: TTablePosition;
     FProducer: THTMLContentProducer;
     FValuePos: TTablePosition;
-    
+    FName : String;
+
     FOnGetValue: TFieldItemEvent;
     FOnGetLabel: TFieldItemEvent;
     FOnGetAction: TFieldItemEvent;
@@ -84,6 +85,8 @@ type
     procedure SetValuePos(const AValue: TTablePosition);
   protected
     procedure AssignTo(Dest: TPersistent); override;
+    Function  GetDisplayName : String; override;
+    Procedure SetDisplayName(AValue : String);
   public
     constructor Create(ACollection: TCollection); override;
     destructor Destroy; override;
@@ -92,6 +95,7 @@ type
     function getAction : String; virtual;
     property Field : TField read FField;
   published
+    Property Name : String Read GetDisplayName Write SetDisplayName;
     property Fieldname : string read FFieldName write FFieldname;
       // the field to show/edit
     property LabelCaption : string read FLabelCaption write FLabelCaption;
@@ -124,6 +128,8 @@ type
   public
     constructor create;
     function AddField (afieldname, acaption : string) : TFormFieldItem;
+    Function FindItem(AName : String): TFormFieldItem;
+    Function IndexofItem(AName : String) : Integer;
     property Items [index : integer] : TFormFieldItem read GetItem write SetItem;
   end;
 
@@ -183,6 +189,7 @@ type
     FCaption: string;
     FCellType: TCellType;
     FChecked: boolean;
+    FDisabled: boolean;
     FColSpan: integer;
     FEndRow: boolean;
     FFormField: TFormFieldItem;
@@ -231,6 +238,8 @@ type
           // MaxLength of text input element
     property Checked : boolean read FChecked write FChecked;
           // checked or not for radio,checkbox
+    property Disabled : boolean read FDisabled write FDisabled;
+          // disabled or not for radio,checkbox
     { only for labels: }
     property Link : string read FLink write FLink;
           // link to place around the text
@@ -465,6 +474,19 @@ begin
       end;
 end;
 
+function TFormFieldItem.GetDisplayName: String;
+begin
+  If (FName='') then
+    FName:=ClassName+IntToStr(self.Index);
+  Result:=FName;
+end;
+
+procedure TFormFieldItem.SetDisplayName(AValue: String);
+begin
+  Inherited;
+  FName:=AValue;
+end;
+
 constructor TFormFieldItem.Create(ACollection: TCollection);
 begin
   inherited Create(ACollection);
@@ -484,7 +506,7 @@ begin
   if inputType in [fitcheckbox,fitradio] then
     Result := 'T'
   else
-    Result := FField.asstring;
+    Result := FField.Text;
   if assigned (FOnGetValue) then
     onGetValue(self,Result);
 end;
@@ -528,6 +550,26 @@ begin
   result.labelcaption := acaption;
 end;
 
+function TFormFieldCollection.FindItem(AName: String): TFormFieldItem;
+Var
+  I : Integer;
+
+begin
+  I:=IndexofItem(AName);
+  If (I=-1) then
+    Result:=Nil
+  else
+    Result:=Items[I];
+end;
+
+function TFormFieldCollection.IndexofItem(AName: String): Integer;
+
+begin
+  Result:=Count-1;
+  While (Result>=0) and (CompareText(Items[Result].Name,AName)<>0) do
+    Dec(Result);
+end;
+
 { TFormButtonItem }
 
 procedure TFormButtonItem.AssignTo(Dest: TPersistent);
@@ -904,6 +946,7 @@ procedure THTMLDatasetFormEditProducer.ControlToTableDef (aControldef : TFormFie
   begin
     with TableDef.CopyTablePosition(aControlDef.ValuePos) do
       begin
+      FormField := aControldef;
       case aControlDef.inputtype of
         fitlabel,
         fittext,
@@ -1051,10 +1094,23 @@ end;
 procedure THTMLDatasetFormGridProducer.ControlToTableDef (aControldef : TFormFieldItem; IsHeader:boolean);
 
   procedure PlaceFieldValue;
+  var check : boolean;
   begin
     with TableDef.CopyTablePosition(aControlDef.ValuePos) do
       begin
-      CellType := ctLabel;
+      if aControldef.InputType = fitcheckbox then
+        begin
+        CellType := ctInput;
+        InputType := aControldef.InputType;
+        Disabled := True;
+        with aControlDef.Field do
+          Check := asBoolean;
+        if assigned (FOnFieldChecked) then
+          FOnFieldChecked (aControlDef.Field, check);
+        Checked := check;
+        end
+      else
+        CellType := ctLabel;
       IsLabel := false;
       Value := aControlDef.getValue;
       Link := aControldef.getAction;
@@ -1142,7 +1198,7 @@ function TTableCell.WriteContent(aWriter: THTMLWriter) : THTMLCustomElement;
           MaxLength := m;
           end;
       fitcheckbox, fitrecordselection :
-        aWriter.FormCheckbox (Name, Value, checked);
+        aWriter.FormCheckbox (Name, Value, checked).disabled := Disabled;
       fitradio :
         aWriter.FormRadio(Name, Value, checked);
       fitfile :

+ 7 - 0
packages/fcl-web/src/fpweb.pp

@@ -52,10 +52,14 @@ Type
   { TFPWebActions }
 
   TFPWebActions = Class(TCustomWebActions)
+  private
+    FCurrentAction : TCustomWebAction;
+  protected
     Procedure HandleRequest(ARequest : TRequest; AResponse : TResponse; Var Handled : Boolean); virtual;
     Procedure GetContent(ARequest : TRequest; Content : TStream; Var Handled : Boolean); virtual;
   Public
     Property ActionVar;
+    Property CurrentAction: TCustomWebAction read FCurrentAction;
   end;
 
   { TTemplateVar }
@@ -512,7 +516,10 @@ begin
 {$ifdef cgidebug}SendMethodEnter('FPWebActions.handlerequest');{$endif cgidebug}
   A:=GetRequestAction(ARequest);
   if Assigned(A) then
+    begin
+    FCurrentAction := A;
     (A as TFPWebAction).HandleRequest(ARequest,AResponse,Handled);
+    end;
 {$ifdef cgidebug}SendMethodExit('FPWebActions.handlerequest');{$endif cgidebug}
 end;