PowerWeb app example - Car Ads (Part 2)

This forum is for conversations about Internet development using CXP, WebSockets, HttpEndPoint, etc.
Post Reply
Message
Author
User avatar
SlavkoDam
Posts: 107
Joined: Wed Apr 27, 2022 10:12 am
Location: Negotin, Serbia
Contact:

PowerWeb app example - Car Ads (Part 2)

#1 Post by SlavkoDam »

Application Car Ads.

This is an application for browsing and editing car ads. HTML pages can be translated to Serbian, English and German language.

Below is the code for creating pages in the application, which are displayed in the following screenshots. You can see in the code that each web UI component is created with a single-function call and its attributes are set in Xbase++ language and style
without HTML/CSS. You can find the complete code in the attachment of the Part 1 post about the new PowerWeb library.

Code: Select all

#include "PwCar.ch"

FUNCTION Car(oSrv)
**
LOCAL aCaps,aCols,aCData,html
**
IF(EMPTY(HASSNGET(oSrv,"Lang")),CarSetLang_(oSrv),.T.)
HACKISET(oSrv,"lang",HASSNGET(oSrv,"Lang"))
HASSNSET(oSrv,"Path",HAPATH(oSrv) + "data\car")
aCaps = HASSNGET(oSrv,"aCaps")
**
aCols = {{"car_id",aCaps[ChdId],,70},;
         {"TRIM(car_brand) + ' ' + TRIM(car_model)",aCaps[ChdName],,250},;
         {"car_year",aCaps[ChdYear],,50},;
         {"car_price",aCaps[ChdPrice],,60,,,,{clrDRed,clrBeige}}}
aCData = {{aCaps[CarBrand]," "},;
          {aCaps[CarModel]," "},;
          {aCaps[CarYear]," "},;
          {aCaps[CarVol]," "},;
          {aCaps[CarPower]," "},;
          {aCaps[CarFuel]," "},;
          {aCaps[CarBody]," "},;
          {aCaps[CarDesc]," "},;
          {aCaps[CarPrice]," "},;
          {aCaps[CarCont]," "}}
**
SET PATH TO (HASSNGET(oSrv,"Path"))
DBOPEN("DBFNTX",{{{"Car"},{"Car"}}},,,.T.)
**
html = HDOCBGN(,{"files/car.js"},,,aCaps[TtlHome],,,,,,,"CarSetLang();") +;
       HDLGBGN(,{1200},aCaps[PhdMain],icoPower,{,{,clrPBlue}},{,,,clrDefBG},;
               {clrBlue,clrDSalmon},,"C") +;
       CarHead(oSrv,aCaps) +;
       HDIVBGN({,1,"R"},{1200,730}) +;
       HHEAD({30},,aCaps[PhdHome],,{,{"mediumblue"}}) +;
       HPARAG({30,70},,aCaps[CarDet_],{{,12,"B"},{"brown"}}) +;
       HBRWPGN({30,110},,,aCols,{,,"CarPage"},,,,,,{"CarDetDisp"}) +;
       HDIVBGN({550,110},{480,540},{,{,clrIvory},,{20,10}},{2,,clrDCyan,10},,,;
               {"CarDet"},,"visibility:hidden") +;
       HIMG(,{350,240},,"Photo",,{8,"R",clrCoral,5},"C",,{"CarImg"}) +;
       HTABLE({,20,"M"},aCData,{{,,,155,,,,"LT"},{,,,300}},,,;
              {{,,.F.},{,,{,clrIvory}}},,{"CarTbl"}) +;
       HSCRP("CarDetDisp(null,'" + TRIM(car_id) + "');") +;
       HDIVEND() + HDIVEND() + HDLGEND() + HDOCEND()
CLOSE
RETURN html

*============================================================================*

FUNCTION CarEdit(oSrv)
**
LOCAL aCaps,aItems[0],html
**
HACKISET(oSrv,"lang",HASSNGET(oSrv,"Lang"))
aCaps = HASSNGET(oSrv,"aCaps")
**
SET PATH TO (HASSNGET(oSrv,"Path"))
DBOPEN("DBFNTX",{{{"Car"},{"Car"}}},,,.T.)
DBEVAL({|| AADD(aItems,{TRIM(car_brand) + " " + TRIM(car_model),TRIM(car_id)})})
**
html = HDOCBGN(,{"files/car.js"},,,aCaps[TtlEdit],,,,,,,"CarSetLang();") +;
       HDLGBGN(,{1200},aCaps[PhdMain],icoPower,{,{,clrPBlue}},{,,,clrDefBG},;
               {clrBlue,clrDSalmon},,"C") +;
       CarHead(oSrv,aCaps) +;
       HDIVBGN({,1,"R"},{1200,790}) +;
       HHEAD({30},,aCaps[PhdEdit],,{,{"mediumblue"}}) +;
       HDIVBGN({500,50}) +;
       HSAY(,{140},,{,12,"BU"},{clrDRed},{"LogUser"}) +;
       HBTN(,{110,30},aCaps[BtnLogi],bmpLogin,,{,,,clrDefBG},,,{"LogiBtn"},,,;
            "CarLogiClk()") +;
       HBTN(,{110,30},aCaps[BtnLogo],bmpLogout,,{,,,clrDefBG},,.T.,{"LogoBtn"},,;
            "margin-left:3px","CarLogoClk()") +;
       HDIVEND() +;
       HDIVBGN({30,90},{840,640},{,{,clrIvory},,10},{,,clrBlue,10}) +;
       HFORMBGN(,,,,"multipart/form-data",,,,,{"CarForm"}) +;
       HFORMTBL(,;
                {{35,aCaps[CarId],{,,40,20},,,,,{"CarId","CarId"}},;
                 {35,aCaps[CarBrand],{,,40,20},,,,,{"CarBrand","CarBrand"}},;
                 {35,aCaps[CarModel],{,,40,25},,,,,{"CarModel","CarModel"}},;
                 {35,aCaps[CarYear],{,,40,4},,,,,{,"CarYear"}},;
                 {35,aCaps[CarVol],{,,40,5},,,,,{,"CarVol"}},;
                 {35,aCaps[CarPower],{,,40,10},,,,,{,"CarPower"}},;
                 {35,aCaps[CarFuel],{,,40,15},,,,,{,"CarFuel"}},;
                 {35,aCaps[CarBody],{,,40,15},,,,,{,"CarBody"}},;
                 {35,aCaps[CarDesc],{,,40,100},,,,,{,"CarDesc"}},;
                 {35,aCaps[CarPrice],{,,40,6},,,,,{,"CarPrice"}},;
                 {35,aCaps[CarCont],{,,40,100},,,,,{,"CarCont"}},;
                 {35,aCaps[CarPhoto],{,,40,100},,,,{,,.T.},{"CarPhoto","CarPhoto"}},;
                 {0,,{0,0},"FU",,,,{"CarUpld","CarUpld"},'ACCEPT="image/*"',,;
                  {,"CarUpldCng(this)"}}},;
                {170,310}) +;
       HFORMEND() +;
       HIMG({186,-98,,"R"},{175,120},,"Photo",,{,,clrMRed,3},,,{"CarImg"}) +;
       HTOOLBAR({380,-155,,"R"},,;
                {{aCaps[BtnLoad],bmpOpenFld,"document.all.CarUpld.click()",,,;
                  {"LoadBtn"},.T.},;
                 {aCaps[BtnClr],bmpClear,"CarClrClk()",,,{"ClrBtn"},.T.}},;
                {{110,30},,{,,,clrDefBG}},,"V") +;
       HTOOLBAR({10,-30,,"R"},,;
                {{aCaps[BtnAdd],bmpNewDoc,"CarAddClk()",,,{"AddBtn"}},;
                 {aCaps[BtnEdit],icoEditText,"CarEditClk()",,,{"EditBtn"},.T.},;
                 {aCaps[BtnDel],icoTrash,"CarDelClk()",,,{"DelBtn"},.T.},;
                 {aCaps[BtnSave],bmpSave,"CarSaveClk()",,,{"SaveBtn"},.T.},;
                 {aCaps[BtnCanc],bmpDelete,"CarCancClk()",,,{"CancBtn"},.T.}},;
                {{110,30},,{,,,clrDefBG}}) +;
       HGET({540,15},{300,300},"LB",,aItems,,{"CarList"},,,{,"CarSelCng()"}) +;
       HDIVEND() +;
       HEDITDATA({{35,aCaps[LogUser],{,,20,20},,,,,{"User","User"}},;
                  {35,aCaps[LogPwrd],{,,20,20},"P",,,,{"Pwrd","Pwrd"}}},;
                 {80,165},aCaps[LogTitle],,,{"LogDlg"},"CarLogAct") +;
       HSCRP(HSETGUI(.T.,.T.) + " GetDisable(1,11); CarSelCng();") +;
       HDIVEND() + HDLGEND() + HDOCEND()
CLOSE
RETURN html

*============================================================================*

FUNCTION CarHead(oSrv,aCaps)
**
RETURN HMENU({3,3,"R"},{450},;
             {{aCaps[MnuHome],bmpHome,"Car"},;
              {aCaps[MnuEdit],icoEdit,"CarEdit",,{,,,,.T.}},;
              {aCaps[MnuExit],bmpExit,"CarExit"}},;
             {,,,{,,,clrDefBG}}) +;
       HDIVBGN({600,-26,"R","R"},{200},{{,,"B"},{clrBlue}}) +;
       HLINK({,,"I"},,"Sr","images/rs.png",,{,{20,13}},,;
             "javascript:CarLangClk('sr')",,,,,"text-decoration:none") +;
       HLINK({20,,"I"},,"En","images/gb.png",,{,{20,13}},,;
             "javascript:CarLangClk('en')",,,,,"text-decoration:none") +;
       HLINK({20,,"I"},,"De","images/de.png",,{,{20,13}},,;
             "javascript:CarLangClk('de-DE')",,,,,"text-decoration:none") +;
       HDIVEND()

*============================================================================*
Image
Image
Best regards,

Slavoljub Damnjanovic
SD-SoftDesign, Alaska Software Technology Partner
https://www.sd-softdesign.com
https://www.sd-softdesign.rs

Post Reply