gnt-all-debug.js 416 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910
  1. // eval
  2. Ext.define("Sch.util.Patch", {
  3. target : null,
  4. minVersion : null,
  5. maxVersion : null,
  6. reportUrl : null,
  7. description : null,
  8. applyFn : null,
  9. ieOnly : false,
  10. onClassExtended : function(a, b) {
  11. if (Sch.disableOverrides) {
  12. return
  13. }
  14. if (b.ieOnly && !Ext.isIE) {
  15. return
  16. }
  17. if ((!b.minVersion || Ext.versions.extjs.equals(b.minVersion) || Ext.versions.extjs
  18. .isGreaterThan(b.minVersion))
  19. && (!b.maxVersion || Ext.versions.extjs.equals(b.maxVersion) || Ext.versions.extjs
  20. .isLessThan(b.maxVersion))) {
  21. if (b.applyFn) {
  22. b.applyFn()
  23. } else {
  24. b.requires[0].override(b.overrides)
  25. }
  26. }
  27. }
  28. });
  29. Ext.define("Sch.patches.LoadMask", {
  30. extend : "Sch.util.Patch",
  31. requires : ["Ext.view.AbstractView"],
  32. minVersion : "4.1.0b3",
  33. //reportURL : "http://www.sencha.com/forum/showthread.php?187700-4.1.0-B3-Ext.AbstractView-no-longer-binds-its-store-to-load-mask",
  34. //description : "In Ext4.1 loadmask no longer bind the store",
  35. overrides : {}
  36. });
  37. Ext.define("Sch.patches.Table", {
  38. extend : "Sch.util.Patch",
  39. requires : ["Ext.view.Table"],
  40. minVersion : "4.1.1",
  41. maxVersion : "4.1.1",
  42. //reportURL : "http://www.sencha.com/forum/showthread.php?238026-4.1.1-Alt-row-styling-lost-after-record-update&p=874190#post874190",
  43. //description : "In Ext4.1.1 when record is updated, the alternate row styling is lost",
  44. overrides : {
  45. onUpdate : function(c, a, b, e) {
  46. var d = this.store.indexOf(a);
  47. this.callParent(arguments);
  48. this.doStripeRows(d, d)
  49. }
  50. }
  51. });
  52. Ext.define("Sch.patches.TreeView", {
  53. extend : "Sch.util.Patch",
  54. requires : ["Ext.tree.View"],
  55. maxVersion : "4.1.3",
  56. applyFn : function() {
  57. Ext.tree.View.addMembers({
  58. providedStore : null,
  59. initComponent : function() {
  60. var a = this, b = a.panel.getStore();
  61. if (a.initialConfig.animate === undefined) {
  62. a.animate = Ext.enableFx
  63. }
  64. a.store = a.providedStore
  65. || new Ext.data.NodeStore({
  66. treeStore : b,
  67. recursive : true,
  68. rootVisible : a.rootVisible
  69. });
  70. a.store.on({
  71. beforeexpand : a.onBeforeExpand,
  72. expand : a.onExpand,
  73. beforecollapse : a.onBeforeCollapse,
  74. collapse : a.onCollapse,
  75. write : a.onStoreWrite,
  76. datachanged : a.onStoreDataChanged,
  77. collapsestart : a.beginBulkUpdate,
  78. collapsecomplete : a.endBulkUpdate,
  79. scope : a
  80. });
  81. if (Ext.versions.extjs
  82. .isGreaterThanOrEqual("4.1.2")) {
  83. a.mon(b, {
  84. scope : a,
  85. beforefill : a.onBeforeFill,
  86. fillcomplete : a.onFillComplete,
  87. beforebulkremove : a.beginBulkUpdate,
  88. bulkremovecomplete : a.endBulkUpdate
  89. });
  90. if (!b.remoteSort) {
  91. a.mon(b, {
  92. scope : a,
  93. beforesort : a.onBeforeSort,
  94. sort : a.onSort
  95. })
  96. }
  97. }
  98. if (a.node && !a.store.node) {
  99. a.setRootNode(a.node)
  100. }
  101. a.animQueue = {};
  102. a.animWraps = {};
  103. a.addEvents("afteritemexpand",
  104. "afteritemcollapse");
  105. a.callParent(arguments);
  106. a.on({
  107. element : "el",
  108. scope : a,
  109. delegate : a.expanderSelector,
  110. mouseover : a.onExpanderMouseOver,
  111. mouseout : a.onExpanderMouseOut
  112. });
  113. a.on({
  114. element : "el",
  115. scope : a,
  116. delegate : a.checkboxSelector,
  117. click : a.onCheckboxChange
  118. })
  119. }
  120. })
  121. }
  122. });
  123. Ext.define("Sch.patches.DataOperation", {
  124. extend : "Sch.util.Patch",
  125. requires : ["Ext.data.Operation"],
  126. //reportURL : "http://www.sencha.com/forum/showthread.php?198894-4.1-Ext.data.TreeStore-CRUD-regression.",
  127. //description : "In Ext 4.1.0 newly created records do not get the Id returned by server applied",
  128. maxVersion : "4.1.0",
  129. overrides : {
  130. commitRecords : function(j) {
  131. var g = this, h, f, a, c, b, d, e;
  132. if (!g.actionSkipSyncRe.test(g.action)) {
  133. a = g.records;
  134. if (a && a.length) {
  135. if (a.length > 1) {
  136. if (g.action == "update" || a[0].clientIdProperty) {
  137. h = new Ext.util.MixedCollection();
  138. h.addAll(j);
  139. for (f = a.length; f--;) {
  140. b = a[f];
  141. c = h.findBy(g.matchClientRec, b);
  142. b.copyFrom(c)
  143. }
  144. } else {
  145. for (d = 0, e = a.length; d < e; ++d) {
  146. b = a[d];
  147. c = j[d];
  148. if (b && c) {
  149. g.updateRecord(b, c)
  150. }
  151. }
  152. }
  153. } else {
  154. this.updateRecord(a[0], j[0])
  155. }
  156. if (g.actionCommitRecordsRe.test(g.action)) {
  157. for (f = a.length; f--;) {
  158. a[f].commit()
  159. }
  160. }
  161. }
  162. }
  163. },
  164. updateRecord : function(a, b) {
  165. if (b && (a.phantom || a.getId() === b.getId())) {
  166. a.copyFrom(b)
  167. }
  168. }
  169. }
  170. });
  171. Ext.define("Sch.patches.TreeStore", {
  172. extend : "Sch.util.Patch",
  173. requires : ["Ext.data.TreeStore"],
  174. //description : "http://www.sencha.com/forum/showthread.php?208602-Model-s-Id-field-not-defined-after-sync-in-TreeStore-%28CRUD%29",
  175. //maxVersion : "4.1.0",
  176. overrides : {
  177. onCreateRecords : function(c) {
  178. this.callParent(arguments);
  179. var d = 0, b = c.length, a = this.tree, e;
  180. for (; d < b; ++d) {
  181. e = c[d];
  182. a.onNodeIdChanged(e, null, e.getId())
  183. }
  184. },
  185. setRootNode : function(a, e) {
  186. var d = this, c = d.model, b = c.prototype.idProperty;
  187. a = a || {};
  188. if (!a.isModel) {
  189. Ext.applyIf(a, {
  190. text : "Root",
  191. allowDrag : false
  192. });
  193. if (a[b] === undefined) {
  194. a[b] = d.defaultRootId
  195. }
  196. Ext.data.NodeInterface.decorate(c);
  197. a = Ext.ModelManager.create(a, c)
  198. } else {
  199. if (a.isModel && !a.isNode) {
  200. Ext.data.NodeInterface.decorate(c)
  201. }
  202. }
  203. d.getProxy().getReader().buildExtractors(true);
  204. d.tree.setRootNode(a);
  205. if (e !== true && !a.isLoaded()
  206. && (d.autoLoad === true || a.isExpanded())) {
  207. d.load({
  208. node : a
  209. })
  210. }
  211. return a
  212. }
  213. }
  214. });
  215. Ext.define("Sch.util.Date", {
  216. requires : "Ext.Date",
  217. singleton : true,
  218. unitHash : null,
  219. unitsByName : {},
  220. unitNames : {
  221. YEAR : {
  222. single : "year",
  223. plural : "years",
  224. abbrev : "yr"
  225. },
  226. QUARTER : {
  227. single : "quarter",
  228. plural : "quarters",
  229. abbrev : "q"
  230. },
  231. MONTH : {
  232. single : "month",
  233. plural : "months",
  234. abbrev : "mon"
  235. },
  236. WEEK : {
  237. single : "week",
  238. plural : "weeks",
  239. abbrev : "w"
  240. },
  241. DAY : {
  242. single : "day",
  243. plural : "days",
  244. abbrev : "d"
  245. },
  246. HOUR : {
  247. single : "hour",
  248. plural : "hours",
  249. abbrev : "h"
  250. },
  251. MINUTE : {
  252. single : "minute",
  253. plural : "minutes",
  254. abbrev : "min"
  255. },
  256. SECOND : {
  257. single : "second",
  258. plural : "seconds",
  259. abbrev : "s"
  260. },
  261. MILLI : {
  262. single : "ms",
  263. plural : "ms",
  264. abbrev : "ms"
  265. }
  266. },
  267. constructor : function() {
  268. var a = Ext.Date;
  269. var c = this.unitHash = {
  270. MILLI : a.MILLI,
  271. SECOND : a.SECOND,
  272. MINUTE : a.MINUTE,
  273. HOUR : a.HOUR,
  274. DAY : a.DAY,
  275. WEEK : "w",
  276. MONTH : a.MONTH,
  277. QUARTER : "q",
  278. YEAR : a.YEAR
  279. };
  280. Ext.apply(this, c);
  281. var b = this;
  282. this.units = [b.MILLI, b.SECOND, b.MINUTE, b.HOUR, b.DAY,
  283. b.WEEK, b.MONTH, b.QUARTER, b.YEAR];
  284. this.setUnitNames(this.unitNames)
  285. },
  286. setUnitNames : function(e) {
  287. var d = this.unitsByName = {};
  288. this.unitNames = e;
  289. var b = this.unitHash;
  290. for (var a in b) {
  291. if (b.hasOwnProperty(a)) {
  292. var c = b[a];
  293. e[c] = e[a];
  294. d[a] = c;
  295. d[c] = c
  296. }
  297. }
  298. },
  299. betweenLesser : function(b, d, a) {
  300. var c = b.getTime();
  301. return d.getTime() <= c && c < a.getTime()
  302. },
  303. constrain : function(b, c, a) {
  304. return this.min(this.max(b, c), a)
  305. },
  306. compareUnits : function(c, b) {
  307. var a = Ext.Array.indexOf(this.units, c), d = Ext.Array
  308. .indexOf(this.units, b);
  309. return a > d ? 1 : (a < d ? -1 : 0)
  310. },
  311. isUnitGreater : function(b, a) {
  312. return this.compareUnits(b, a) > 0
  313. },
  314. copyTimeValues : function(b, a) {
  315. b.setHours(a.getHours());
  316. b.setMinutes(a.getMinutes());
  317. b.setSeconds(a.getSeconds());
  318. b.setMilliseconds(a.getMilliseconds())
  319. },
  320. add : function(b, c, e) {
  321. var f = Ext.Date.clone(b);
  322. if (!c || e === 0) {
  323. return f
  324. }
  325. switch (c.toLowerCase()) {
  326. case this.MILLI :
  327. f = new Date(b.getTime() + e);
  328. break;
  329. case this.SECOND :
  330. f = new Date(b.getTime() + (e * 1000));
  331. break;
  332. case this.MINUTE :
  333. f = new Date(b.getTime() + (e * 60000));
  334. break;
  335. case this.HOUR :
  336. f = new Date(b.getTime() + (e * 3600000));
  337. break;
  338. case this.DAY :
  339. f.setDate(b.getDate() + e);
  340. break;
  341. case this.WEEK :
  342. f.setDate(b.getDate() + e * 7);
  343. break;
  344. case this.MONTH :
  345. var a = b.getDate();
  346. if (a > 28) {
  347. a = Math.min(a,
  348. Ext.Date.getLastDateOfMonth(this.add(
  349. Ext.Date.getFirstDateOfMonth(b),
  350. this.MONTH, e)).getDate())
  351. }
  352. f.setDate(a);
  353. f.setMonth(f.getMonth() + e);
  354. break;
  355. case this.QUARTER :
  356. f = this.add(b, this.MONTH, e * 3);
  357. break;
  358. case this.YEAR :
  359. f.setFullYear(b.getFullYear() + e);
  360. break
  361. }
  362. return f
  363. },
  364. getMeasuringUnit : function(a) {
  365. if (a === this.WEEK) {
  366. return this.DAY
  367. }
  368. return a
  369. },
  370. getDurationInUnit : function(d, a, c) {
  371. var b;
  372. switch (c) {
  373. case this.YEAR :
  374. b = Math.round(this.getDurationInYears(d, a));
  375. break;
  376. case this.QUARTER :
  377. b = Math.round(this.getDurationInMonths(d, a) / 3);
  378. break;
  379. case this.MONTH :
  380. b = Math.round(this.getDurationInMonths(d, a));
  381. break;
  382. case this.WEEK :
  383. b = Math.round(this.getDurationInDays(d, a)) / 7;
  384. break;
  385. case this.DAY :
  386. b = Math.round(this.getDurationInDays(d, a));
  387. break;
  388. case this.HOUR :
  389. b = Math.round(this.getDurationInHours(d, a));
  390. break;
  391. case this.MINUTE :
  392. b = Math.round(this.getDurationInMinutes(d, a));
  393. break;
  394. case this.SECOND :
  395. b = Math.round(this.getDurationInSeconds(d, a));
  396. break;
  397. case this.MILLI :
  398. b = Math.round(this.getDurationInMilliseconds(d, a));
  399. break
  400. }
  401. return b
  402. },
  403. getUnitToBaseUnitRatio : function(b, a) {
  404. if (b === a) {
  405. return 1
  406. }
  407. switch (b) {
  408. case this.YEAR :
  409. switch (a) {
  410. case this.QUARTER :
  411. return 1 / 4;
  412. case this.MONTH :
  413. return 1 / 12
  414. }
  415. break;
  416. case this.QUARTER :
  417. switch (a) {
  418. case this.YEAR :
  419. return 4;
  420. case this.MONTH :
  421. return 1 / 3
  422. }
  423. break;
  424. case this.MONTH :
  425. switch (a) {
  426. case this.YEAR :
  427. return 12;
  428. case this.QUARTER :
  429. return 3
  430. }
  431. break;
  432. case this.WEEK :
  433. switch (a) {
  434. case this.DAY :
  435. return 1 / 7;
  436. case this.HOUR :
  437. return 1 / 168
  438. }
  439. break;
  440. case this.DAY :
  441. switch (a) {
  442. case this.WEEK :
  443. return 7;
  444. case this.HOUR :
  445. return 1 / 24;
  446. case this.MINUTE :
  447. return 1 / 1440
  448. }
  449. break;
  450. case this.HOUR :
  451. switch (a) {
  452. case this.DAY :
  453. return 24;
  454. case this.MINUTE :
  455. return 1 / 60
  456. }
  457. break;
  458. case this.MINUTE :
  459. switch (a) {
  460. case this.HOUR :
  461. return 60;
  462. case this.SECOND :
  463. return 1 / 60;
  464. case this.MILLI :
  465. return 1 / 60000
  466. }
  467. break;
  468. case this.SECOND :
  469. switch (a) {
  470. case this.MILLI :
  471. return 1 / 1000
  472. }
  473. break;
  474. case this.MILLI :
  475. switch (a) {
  476. case this.SECOND :
  477. return 1000
  478. }
  479. break
  480. }
  481. return -1
  482. },
  483. getDurationInMilliseconds : function(b, a) {
  484. return (a - b)
  485. },
  486. getDurationInSeconds : function(b, a) {
  487. return (a - b) / 1000
  488. },
  489. getDurationInMinutes : function(b, a) {
  490. return (a - b) / 60000
  491. },
  492. getDurationInHours : function(b, a) {
  493. return (a - b) / 3600000
  494. },
  495. getDurationInDays : function(b, a) {
  496. return (a - b) / 86400000
  497. },
  498. getDurationInBusinessDays : function(g, b) {
  499. var c = Math.round((b - g) / 86400000), a = 0, f;
  500. for (var e = 0; e < c; e++) {
  501. f = this.add(g, this.DAY, e).getDay();
  502. if (f !== 6 && f !== 0) {
  503. a++
  504. }
  505. }
  506. return a
  507. },
  508. getDurationInMonths : function(b, a) {
  509. return ((a.getFullYear() - b.getFullYear()) * 12)
  510. + (a.getMonth() - b.getMonth())
  511. },
  512. getDurationInYears : function(b, a) {
  513. return this.getDurationInMonths(b, a) / 12
  514. },
  515. min : function(b, a) {
  516. return b < a ? b : a
  517. },
  518. max : function(b, a) {
  519. return b > a ? b : a
  520. },
  521. intersectSpans : function(c, d, b, a) {
  522. return this.betweenLesser(c, b, a)
  523. || this.betweenLesser(b, c, d)
  524. },
  525. getNameOfUnit : function(a) {
  526. a = this.getUnitByName(a);
  527. switch (a.toLowerCase()) {
  528. case this.YEAR :
  529. return "YEAR";
  530. case this.QUARTER :
  531. return "QUARTER";
  532. case this.MONTH :
  533. return "MONTH";
  534. case this.WEEK :
  535. return "WEEK";
  536. case this.DAY :
  537. return "DAY";
  538. case this.HOUR :
  539. return "HOUR";
  540. case this.MINUTE :
  541. return "MINUTE";
  542. case this.SECOND :
  543. return "SECOND";
  544. case this.MILLI :
  545. return "MILLI"
  546. }
  547. throw "Incorrect UnitName"
  548. },
  549. getReadableNameOfUnit : function(b, a) {
  550. return this.unitNames[b][a ? "plural" : "single"]
  551. },
  552. getShortNameOfUnit : function(a) {
  553. return this.unitNames[a].abbrev
  554. },
  555. getUnitByName : function(a) {
  556. if (!this.unitsByName[a]) {
  557. Ext.Error.raise("Unknown unit name: " + a)
  558. }
  559. return this.unitsByName[a]
  560. },
  561. getNext : function(c, g, a, f) {
  562. var e = Ext.Date.clone(c);
  563. f = arguments.length < 4 ? 1 : f;
  564. a = a || 1;
  565. switch (g) {
  566. case this.MILLI :
  567. e = this.add(c, g, a);
  568. break;
  569. case this.SECOND :
  570. e = this.add(c, g, a);
  571. e.setMilliseconds(0);
  572. break;
  573. case this.MINUTE :
  574. e = this.add(c, g, a);
  575. e.setSeconds(0);
  576. e.setMilliseconds(0);
  577. break;
  578. case this.HOUR :
  579. e = this.add(c, g, a);
  580. e.setMinutes(0);
  581. e.setSeconds(0);
  582. e.setMilliseconds(0);
  583. break;
  584. case this.DAY :
  585. var d = c.getHours() === 23
  586. && this.add(e, this.HOUR, 1).getHours() === 1;
  587. if (d) {
  588. e = this.add(e, this.DAY, 2);
  589. Ext.Date.clearTime(e);
  590. return e
  591. }
  592. Ext.Date.clearTime(e);
  593. e = this.add(e, this.DAY, a);
  594. break;
  595. case this.WEEK :
  596. Ext.Date.clearTime(e);
  597. var b = e.getDay();
  598. e = this.add(e, this.DAY, f - b + 7
  599. * (a - (f <= b ? 0 : 1)));
  600. if (e.getDay() !== f) {
  601. e = this.add(e, this.HOUR, 1)
  602. } else {
  603. Ext.Date.clearTime(e)
  604. }
  605. break;
  606. case this.MONTH :
  607. e = this.add(e, this.MONTH, a);
  608. e.setDate(1);
  609. Ext.Date.clearTime(e);
  610. break;
  611. case this.QUARTER :
  612. e = this.add(e, this.MONTH, ((a - 1) * 3)
  613. + (3 - (e.getMonth() % 3)));
  614. Ext.Date.clearTime(e);
  615. e.setDate(1);
  616. break;
  617. case this.YEAR :
  618. e = new Date(e.getFullYear() + a, 0, 1);
  619. break;
  620. default :
  621. throw "Invalid date unit"
  622. }
  623. return e
  624. },
  625. getNumberOfMsFromTheStartOfDay : function(a) {
  626. return a - Ext.Date.clearTime(a, true) || 86400000
  627. },
  628. getNumberOfMsTillTheEndOfDay : function(a) {
  629. return this.getStartOfNextDay(a, true) - a
  630. },
  631. getStartOfNextDay : function(b, e) {
  632. var d = this.add(Ext.Date.clearTime(b, e), this.DAY, 1);
  633. if (d.getDate() == b.getDate()) {
  634. var c = this.add(Ext.Date.clearTime(b, e), this.DAY, 2)
  635. .getTimezoneOffset();
  636. var a = b.getTimezoneOffset();
  637. d = this.add(d, this.MINUTE, a - c)
  638. }
  639. return d
  640. },
  641. getEndOfPreviousDay : function(b) {
  642. var a = Ext.Date.clearTime(b, true);
  643. if (a - b) {
  644. return a
  645. } else {
  646. return this.add(a, this.DAY, -1)
  647. }
  648. },
  649. timeSpanContains : function(c, b, d, a) {
  650. return (d - c) >= 0 && (b - a) >= 0
  651. }
  652. });
  653. Ext.define("Sch.util.DragTracker", {
  654. extend : "Ext.dd.DragTracker",
  655. xStep : 1,
  656. yStep : 1,
  657. setXStep : function(a) {
  658. this.xStep = a
  659. },
  660. setYStep : function(a) {
  661. this.yStep = a
  662. },
  663. getRegion : function() {
  664. var e = this.startXY, d = this.getXY(), b = Math.min(e[0], d[0]), f = Math
  665. .min(e[1], d[1]), c = Math.abs(e[0] - d[0]), a = Math.abs(e[1]
  666. - d[1]);
  667. return new Ext.util.Region(f, b + c, f + a, b)
  668. },
  669. onMouseDown : function(f, d) {
  670. if (this.disabled || f.dragTracked) {
  671. return
  672. }
  673. var c = f.getXY(), g, b, a = c[0], h = c[1];
  674. if (this.xStep > 1) {
  675. g = this.el.getX();
  676. a -= g;
  677. a = Math.round(a / this.xStep) * this.xStep;
  678. a += g
  679. }
  680. if (this.yStep > 1) {
  681. b = this.el.getY();
  682. h -= b;
  683. h = Math.round(h / this.yStep) * this.yStep;
  684. h += b
  685. }
  686. this.dragTarget = this.delegate ? d : this.handle.dom;
  687. this.startXY = this.lastXY = [a, h];
  688. this.startRegion = Ext.fly(this.dragTarget).getRegion();
  689. if (this.fireEvent("mousedown", this, f) === false
  690. || this.fireEvent("beforedragstart", this, f) === false
  691. || this.onBeforeStart(f) === false) {
  692. return
  693. }
  694. this.mouseIsDown = true;
  695. f.dragTracked = true;
  696. if (this.preventDefault !== false) {
  697. f.preventDefault()
  698. }
  699. Ext.getDoc().on({
  700. scope : this,
  701. mouseup : this.onMouseUp,
  702. mousemove : this.onMouseMove,
  703. selectstart : this.stopSelect
  704. });
  705. if (this.autoStart) {
  706. this.timer = Ext.defer(this.triggerStart, this.autoStart === true
  707. ? 1000
  708. : this.autoStart, this, [f])
  709. }
  710. },
  711. onMouseMove : function(g, f) {
  712. if (this.active && Ext.isIE && !g.browserEvent.button) {
  713. g.preventDefault();
  714. this.onMouseUp(g);
  715. return
  716. }
  717. g.preventDefault();
  718. var d = g.getXY(), b = this.startXY;
  719. if (!this.active) {
  720. if (Math.max(Math.abs(b[0] - d[0]), Math.abs(b[1] - d[1])) > this.tolerance) {
  721. this.triggerStart(g)
  722. } else {
  723. return
  724. }
  725. }
  726. var a = d[0], h = d[1];
  727. if (this.xStep > 1) {
  728. a -= this.startXY[0];
  729. a = Math.round(a / this.xStep) * this.xStep;
  730. a += this.startXY[0]
  731. }
  732. if (this.yStep > 1) {
  733. h -= this.startXY[1];
  734. h = Math.round(h / this.yStep) * this.yStep;
  735. h += this.startXY[1]
  736. }
  737. var c = this.xStep > 1 || this.yStep > 1;
  738. if (!c || a !== d[0] || h !== d[1]) {
  739. this.lastXY = [a, h];
  740. if (this.fireEvent("mousemove", this, g) === false) {
  741. this.onMouseUp(g)
  742. } else {
  743. this.onDrag(g);
  744. this.fireEvent("drag", this, g)
  745. }
  746. }
  747. }
  748. });
  749. Ext.define("Sch.util.HeaderRenderers", {
  750. singleton : true,
  751. requires : ["Sch.util.Date", "Ext.XTemplate"],
  752. constructor : function() {
  753. var b = Ext
  754. .create(
  755. "Ext.XTemplate",
  756. '<table class="sch-nested-hdr-tbl '
  757. + Ext.baseCSSPrefix
  758. + 'column-header-text" cellpadding="0" cellspacing="0"><tr><tpl for="."><td style="width:{[100/xcount]}%" class="{cls} sch-dayheadercell-{dayOfWeek}">{text}</td></tpl></tr></table>')
  759. .compile();
  760. var a = Ext
  761. .create(
  762. "Ext.XTemplate",
  763. '<table class="sch-nested-hdr-tbl" cellpadding="0" cellspacing="0"><tr><tpl for="."><td style="width:{[100/xcount]}%" class="{cls}">{text}</td></tpl></tr></table>')
  764. .compile();
  765. return {
  766. quarterMinute : function(f, d, c, e) {
  767. c.headerCls = "sch-nested-hdr-pad";
  768. return '<table class="sch-nested-hdr-tbl" cellpadding="0" cellspacing="0"><tr><td>00</td><td>15</td><td>30</td><td>45</td></tr></table>'
  769. },
  770. dateCells : function(d, c, e) {
  771. return function(j, g, f) {
  772. f.headerCls = "sch-nested-hdr-nopad";
  773. var i = [], h = Ext.Date.clone(j);
  774. while (h < g) {
  775. i.push({
  776. text : Ext.Date.format(h, e)
  777. });
  778. h = Sch.util.Date.add(h, d, c)
  779. }
  780. i[0].cls = "sch-nested-hdr-cell-first";
  781. i[i.length - 1].cls = "sch-nested-hdr-cell-last";
  782. return a.apply(i)
  783. }
  784. },
  785. dateNumber : function(g, d, c) {
  786. c.headerCls = "sch-nested-hdr-nopad";
  787. var f = [], e = Ext.Date.clone(g);
  788. while (e < d) {
  789. f.push({
  790. dayOfWeek : e.getDay(),
  791. text : e.getDate()
  792. });
  793. e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1)
  794. }
  795. return b.apply(f)
  796. },
  797. dayLetter : function(g, d, c) {
  798. c.headerCls = "sch-nested-hdr-nopad";
  799. var f = [], e = g;
  800. while (e < d) {
  801. f.push({
  802. dayOfWeek : e.getDay(),
  803. text : Ext.Date.dayNames[e.getDay()].substr(0,
  804. 1)
  805. });
  806. e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1)
  807. }
  808. f[0].cls = "sch-nested-hdr-cell-first";
  809. f[f.length - 1].cls = "sch-nested-hdr-cell-last";
  810. return b.apply(f)
  811. },
  812. dayStartEndHours : function(e, d, c) {
  813. c.headerCls = "sch-hdr-startend";
  814. return Ext.String
  815. .format(
  816. '<span class="sch-hdr-start">{0}</span><span class="sch-hdr-end">{1}</span>',
  817. Ext.Date.format(e, "G"), Ext.Date
  818. .format(d, "G"))
  819. }
  820. }
  821. }
  822. });
  823. Ext.define("Sch.model.Customizable", {
  824. extend : "Ext.data.Model",
  825. customizableFields : null,
  826. onClassExtended : function(b, d, a) {
  827. var c = a.onBeforeCreated;
  828. a.onBeforeCreated = function(f, k) {
  829. c.call(this, f, k);
  830. var j = f.prototype;
  831. if (!j.customizableFields) {
  832. return
  833. }
  834. j.customizableFields = (f.superclass.customizableFields || [])
  835. .concat(j.customizableFields);
  836. var g = j.customizableFields;
  837. var i = {};
  838. Ext.Array.each(g, function(l) {
  839. if (typeof l == "string") {
  840. l = {
  841. name : l
  842. }
  843. }
  844. i[l.name] = l
  845. });
  846. var e = j.fields;
  847. var h = [];
  848. e.each(function(l) {
  849. if (l.isCustomizableField) {
  850. h.push(l)
  851. }
  852. });
  853. e.removeAll(h);
  854. Ext.Object.each(i, function(l, o) {
  855. o.isCustomizableField = true;
  856. var p = o.name;
  857. var t = p === "Id" ? "idProperty" : p.charAt(0).toLowerCase()
  858. + p.substr(1) + "Field";
  859. var q = j[t];
  860. var s = q || p;
  861. if (e.containsKey(s)) {
  862. e.getByKey(s).isCustomizableField = true;
  863. g.push(new Ext.data.Field(Ext.applyIf({
  864. name : p,
  865. isCustomizableField : true
  866. }, e.getByKey(s))))
  867. } else {
  868. e.add(new Ext.data.Field(Ext.applyIf({
  869. name : s,
  870. isCustomizableField : true
  871. }, o)))
  872. }
  873. var n = Ext.String.capitalize(p);
  874. if (n != "Id") {
  875. var r = "get" + n;
  876. var m = "set" + n;
  877. if (!j[r] || j[r].__getterFor__ && j[r].__getterFor__ != s) {
  878. j[r] = function() {
  879. return this.data[s]
  880. };
  881. j[r].__getterFor__ = s
  882. }
  883. if (!j[m] || j[m].__setterFor__ && j[m].__setterFor__ != s) {
  884. j[m] = function(u) {
  885. return this.set(s, u)
  886. };
  887. j[m].__setterFor__ = s
  888. }
  889. }
  890. })
  891. }
  892. },
  893. set : function(c, b) {
  894. if (arguments.length === 2) {
  895. this.previous = this.previous || {};
  896. var a = this.get(c);
  897. if (a !== b) {
  898. this.previous[c] = a
  899. }
  900. }
  901. this.callParent(arguments)
  902. },
  903. afterEdit : function() {
  904. this.callParent(arguments);
  905. delete this.previous
  906. },
  907. reject : function() {
  908. var b = this, a = b.modified, c;
  909. b.previous = b.previous || {};
  910. for (c in a) {
  911. if (a.hasOwnProperty(c)) {
  912. if (typeof a[c] != "function") {
  913. b.previous[c] = b.get(c)
  914. }
  915. }
  916. }
  917. b.callParent(arguments);
  918. delete b.previous
  919. }
  920. });
  921. Ext.define("Sch.patches.Model", {
  922. extend : "Sch.util.Patch",
  923. requires : "Sch.model.Customizable",
  924. //reportURL : "http://www.sencha.com/forum/showthread.php?198250-4.1-Ext.data.Model-regression",
  925. //description : "In Ext 4.1 Models cannot be subclassed",
  926. maxVersion : "4.1.0",
  927. applyFn : function() {
  928. try {
  929. Ext.define("Sch.foo", {
  930. extend : "Ext.data.Model",
  931. fields : ["a"]
  932. });
  933. Ext.define("Sch.foo.Sub", {
  934. extend : "Sch.foo",
  935. fields : ["a"]
  936. })
  937. } catch (a) {
  938. Ext.data.Types.AUTO.convert = function(b) {
  939. return b
  940. }
  941. }
  942. }
  943. });
  944. Ext.define("Sch.data.mixin.EventStore", {
  945. model : "Sch.model.Event",
  946. requires : ["Sch.util.Date"],
  947. isEventStore : true,
  948. setResourceStore : function(a) {
  949. if (this.resourceStore) {
  950. this.resourceStore.un({
  951. beforesync : this.onResourceStoreBeforeSync,
  952. write : this.onResourceStoreWrite,
  953. scope : this
  954. })
  955. }
  956. this.resourceStore = a;
  957. if (a) {
  958. a.on({
  959. beforesync : this.onResourceStoreBeforeSync,
  960. write : this.onResourceStoreWrite,
  961. scope : this
  962. })
  963. }
  964. },
  965. onResourceStoreBeforeSync : function(b, c) {
  966. var a = b.create;
  967. if (a) {
  968. for (var e, d = a.length - 1; d >= 0; d--) {
  969. e = a[d];
  970. e._phantomId = e.internalId
  971. }
  972. }
  973. },
  974. onResourceStoreWrite : function(c, b) {
  975. if (b.wasSuccessful()) {
  976. var d = this, a = b.getRecords();
  977. Ext.each(a, function(e) {
  978. if (e._phantomId && !e.phantom) {
  979. d.each(function(f) {
  980. if (f.getResourceId() === e._phantomId) {
  981. f.assign(e)
  982. }
  983. })
  984. }
  985. })
  986. }
  987. },
  988. isDateRangeAvailable : function(f, a, b, d) {
  989. var c = true, e = Sch.util.Date;
  990. this.each(function(g) {
  991. if (e
  992. .intersectSpans(f, a, g.getStartDate(), g
  993. .getEndDate())
  994. && d === g.getResource() && (!b || b !== g)) {
  995. c = false;
  996. return false
  997. }
  998. });
  999. return c
  1000. },
  1001. getEventsInTimeSpan : function(d, b, a) {
  1002. if (a !== false) {
  1003. var c = Sch.util.Date;
  1004. return this.queryBy(function(g) {
  1005. var f = g.getStartDate(), e = g.getEndDate();
  1006. return f && e && c.intersectSpans(f, e, d, b)
  1007. })
  1008. } else {
  1009. return this.queryBy(function(g) {
  1010. var f = g.getStartDate(), e = g.getEndDate();
  1011. return f && e && (f - d >= 0) && (b - e >= 0)
  1012. })
  1013. }
  1014. },
  1015. getTotalTimeSpan : function() {
  1016. var a = new Date(9999, 0, 1), b = new Date(0), c = Sch.util.Date;
  1017. this.each(function(d) {
  1018. if (d.getStartDate()) {
  1019. a = c.min(d.getStartDate(), a)
  1020. }
  1021. if (d.getEndDate()) {
  1022. b = c.max(d.getEndDate(), b)
  1023. }
  1024. });
  1025. a = a < new Date(9999, 0, 1) ? a : null;
  1026. b = b > new Date(0) ? b : null;
  1027. return {
  1028. start : a || null,
  1029. end : b || a || null
  1030. }
  1031. },
  1032. getEventsForResource : function(e) {
  1033. var c = [], d, f = e.getId() || e.internalId;
  1034. for (var b = 0, a = this.getCount(); b < a; b++) {
  1035. d = this.getAt(b);
  1036. if (d.data[d.resourceIdField] === f) {
  1037. c.push(d)
  1038. }
  1039. }
  1040. return c
  1041. },
  1042. getClosestSuccessor : function(g, e) {
  1043. var c = Infinity, a = g.getEnd(), f, h;
  1044. e = e || this.getRange();
  1045. for (var d = 0, b = e.length; d < b; d++) {
  1046. h = e[d].getStart() - a;
  1047. if (h >= 0 && h < c) {
  1048. f = e[d];
  1049. c = h
  1050. }
  1051. }
  1052. return f
  1053. }
  1054. });
  1055. Ext.define("Sch.model.Range", {
  1056. extend : "Sch.model.Customizable",
  1057. requires : ["Sch.util.Date", "Sch.patches.DataOperation"],
  1058. startDateField : "StartDate",
  1059. endDateField : "EndDate",
  1060. nameField : "Name",
  1061. clsField : "Cls",
  1062. customizableFields : [{
  1063. name : "StartDate",
  1064. type : "date",
  1065. dateFormat : "c"
  1066. }, {
  1067. name : "EndDate",
  1068. type : "date",
  1069. dateFormat : "c"
  1070. }, {
  1071. name : "Cls",
  1072. type : "string"
  1073. }, {
  1074. name : "Name",
  1075. type : "string"
  1076. }],
  1077. setStartDate : function(a, d) {
  1078. var c = this.getEndDate();
  1079. var b = this.getStartDate();
  1080. this.set(this.startDateField, a);
  1081. if (d === true && c && b) {
  1082. this.setEndDate(Sch.util.Date.add(a, Sch.util.Date.MILLI, c - b))
  1083. }
  1084. },
  1085. setEndDate : function(b, d) {
  1086. var a = this.getStartDate();
  1087. var c = this.getEndDate();
  1088. this.set(this.endDateField, b);
  1089. if (d === true && a && c) {
  1090. this.setStartDate(Sch.util.Date.add(b, Sch.util.Date.MILLI,
  1091. -(c - a)))
  1092. }
  1093. },
  1094. setStartEndDate : function(b, a) {
  1095. this.beginEdit();
  1096. this.set(this.startDateField, b);
  1097. this.set(this.endDateField, a);
  1098. this.endEdit()
  1099. },
  1100. getDates : function() {
  1101. var c = [], b = this.getEndDate();
  1102. for (var a = Ext.Date.clearTime(this.getStartDate(), true); a < b; a = Sch.util.Date
  1103. .add(a, Sch.util.Date.DAY, 1)) {
  1104. c.push(a)
  1105. }
  1106. return c
  1107. },
  1108. forEachDate : function(b, a) {
  1109. return Ext.each(this.getDates(), b, a)
  1110. },
  1111. isValid : function() {
  1112. var b = this.callParent(arguments);
  1113. if (b) {
  1114. var c = this.getStartDate(), a = this.getEndDate();
  1115. b = !c || !a || (a - c >= 0)
  1116. }
  1117. return b
  1118. },
  1119. shift : function(b, a) {
  1120. this.setStartEndDate(Sch.util.Date.add(this.getStartDate(), b, a),
  1121. Sch.util.Date.add(this.getEndDate(), b, a))
  1122. }
  1123. });
  1124. Ext.define("Sch.model.Resource", {
  1125. extend : "Sch.model.Customizable",
  1126. idProperty : "Id",
  1127. nameField : "Name",
  1128. customizableFields : ["Id", {
  1129. name : "Name",
  1130. type : "string"
  1131. }],
  1132. getEventStore : function() {
  1133. return this.stores[0] && this.stores[0].eventStore
  1134. || this.parentNode && this.parentNode.getEventStore()
  1135. },
  1136. getEvents : function(d) {
  1137. var c = [], e, f = this.getId() || this.internalId;
  1138. d = d || this.getEventStore();
  1139. for (var b = 0, a = d.getCount(); b < a; b++) {
  1140. e = d.getAt(b);
  1141. if (e.data[e.resourceIdField] === f) {
  1142. c.push(e)
  1143. }
  1144. }
  1145. return c
  1146. }
  1147. });
  1148. Ext.define("Sch.data.mixin.ResourceStore", {});
  1149. Ext.define("Sch.data.FilterableNodeStore", {
  1150. extend : "Ext.data.NodeStore",
  1151. onNodeExpand : function(f, d, c) {
  1152. var b = [];
  1153. for (var e = 0; e < d.length; e++) {
  1154. var a = d[e];
  1155. if (!(a.isHidden && a.isHidden() || a.hidden || a.data.hidden)) {
  1156. b[b.length] = a
  1157. }
  1158. }
  1159. return this.callParent([f, b, c])
  1160. }
  1161. });
  1162. Ext.define("Sch.data.mixin.FilterableTreeStore", {
  1163. requires : ["Sch.data.FilterableNodeStore"],
  1164. nodeStoreClassName : "Sch.data.FilterableNodeStore",
  1165. nodeStore : null,
  1166. isFilteredFlag : false,
  1167. initTreeFiltering : function() {
  1168. if (!this.nodeStore) {
  1169. this.nodeStore = this.createNodeStore(this)
  1170. }
  1171. this.addEvents("filter-set", "filter-clear",
  1172. "nodestore-datachange-start", "nodestore-datachange-end")
  1173. },
  1174. createNodeStore : function(a) {
  1175. return Ext.create(this.nodeStoreClassName, {
  1176. treeStore : a,
  1177. recursive : true,
  1178. rootVisible : this.rootVisible
  1179. })
  1180. },
  1181. clearTreeFilter : function() {
  1182. if (!this.isTreeFiltered()) {
  1183. return
  1184. }
  1185. this.refreshNodeStoreContent();
  1186. this.isFilteredFlag = false;
  1187. this.fireEvent("filter-clear", this)
  1188. },
  1189. refreshNodeStoreContent : function(f) {
  1190. var a = this.getRootNode(), d = [];
  1191. var c = this.rootVisible;
  1192. var b = function(i) {
  1193. if (i.isHidden && i.isHidden() || i.hidden || i.data.hidden) {
  1194. return
  1195. }
  1196. if (c || i != a) {
  1197. d[d.length] = i
  1198. }
  1199. if (!i.data.leaf && i.isExpanded()) {
  1200. var j = i.childNodes, h = j.length;
  1201. for (var g = 0; g < h; g++) {
  1202. b(j[g])
  1203. }
  1204. }
  1205. };
  1206. b(a);
  1207. this.fireEvent("nodestore-datachange-start", this);
  1208. var e = this.nodeStore;
  1209. if (!this.loadDataInNodeStore || !this.loadDataInNodeStore(d)) {
  1210. e.loadRecords(d)
  1211. }
  1212. if (!f) {
  1213. e.fireEvent("clear", e)
  1214. }
  1215. this.fireEvent("nodestore-datachange-end", this)
  1216. },
  1217. getIndexInTotalDataset : function(b) {
  1218. var a = this.getRootNode();
  1219. index = -1;
  1220. var d = this.rootVisible;
  1221. if (!d && b == a) {
  1222. return -1
  1223. }
  1224. var c = function(g) {
  1225. if (g.isHidden && g.isHidden() || g.hidden || g.data.hidden) {
  1226. if (g == b) {
  1227. return false
  1228. }
  1229. }
  1230. if (d || g != a) {
  1231. index++
  1232. }
  1233. if (g == b) {
  1234. return false
  1235. }
  1236. if (!g.data.leaf && g.isExpanded()) {
  1237. var h = g.childNodes, f = h.length;
  1238. for (var e = 0; e < f; e++) {
  1239. if (c(h[e]) === false) {
  1240. return false
  1241. }
  1242. }
  1243. }
  1244. };
  1245. c(a);
  1246. return index
  1247. },
  1248. isTreeFiltered : function() {
  1249. return this.isFilteredFlag
  1250. },
  1251. filterTreeBy : function(s, b) {
  1252. var g;
  1253. if (arguments.length == 1 && Ext.isObject(arguments[0])) {
  1254. b = s.scope;
  1255. g = s.filter
  1256. } else {
  1257. g = s;
  1258. s = {}
  1259. }
  1260. this.fireEvent("nodestore-datachange-start", this);
  1261. s = s || {};
  1262. var j = s.shallow;
  1263. var r = s.checkParents || j;
  1264. var h = s.fullMathchingParents;
  1265. var c = s.onlyParents || h;
  1266. var e = this.rootVisible;
  1267. if (c && r) {
  1268. throw new Error("Can't combine `onlyParents` and `checkParents` options")
  1269. }
  1270. var o = {};
  1271. var m = this.getRootNode(), d = [];
  1272. var a = function(t) {
  1273. var i = t.parentNode;
  1274. while (i && !o[i.internalId]) {
  1275. o[i.internalId] = true;
  1276. i = i.parentNode
  1277. }
  1278. };
  1279. var k = function(v) {
  1280. if (v.isHidden && v.isHidden() || v.hidden || v.data.hidden) {
  1281. return
  1282. }
  1283. var t, w, u, i;
  1284. if (v.data.leaf) {
  1285. if (g.call(b, v, o)) {
  1286. d[d.length] = v;
  1287. a(v)
  1288. }
  1289. } else {
  1290. if (e || v != m) {
  1291. d[d.length] = v
  1292. }
  1293. if (c) {
  1294. t = g.call(b, v);
  1295. w = v.childNodes;
  1296. u = w.length;
  1297. if (t) {
  1298. o[v.internalId] = true;
  1299. a(v);
  1300. if (h) {
  1301. v.cascadeBy(function(x) {
  1302. d[d.length] = x;
  1303. if (!x.data.leaf) {
  1304. o[x.internalId] = true
  1305. }
  1306. });
  1307. return
  1308. }
  1309. }
  1310. for (i = 0; i < u; i++) {
  1311. if (t && w[i].data.leaf) {
  1312. d[d.length] = w[i]
  1313. } else {
  1314. if (!w[i].data.leaf) {
  1315. k(w[i])
  1316. }
  1317. }
  1318. }
  1319. } else {
  1320. if (r) {
  1321. t = g.call(b, v, o);
  1322. if (t) {
  1323. o[v.internalId] = true;
  1324. a(v)
  1325. }
  1326. }
  1327. if (!r || !j || j && (t || v == m && !e)) {
  1328. w = v.childNodes;
  1329. u = w.length;
  1330. for (i = 0; i < u; i++) {
  1331. k(w[i])
  1332. }
  1333. }
  1334. }
  1335. }
  1336. };
  1337. k(m);
  1338. var f = [];
  1339. for (var p = 0, q = d.length; p < q; p++) {
  1340. var l = d[p];
  1341. if (l.data.leaf || o[l.internalId]) {
  1342. f[f.length] = l
  1343. }
  1344. }
  1345. var n = this.nodeStore;
  1346. if (!this.loadDataInNodeStore || !this.loadDataInNodeStore(f)) {
  1347. n.loadRecords(f, false);
  1348. n.fireEvent("clear", n)
  1349. }
  1350. this.isFilteredFlag = true;
  1351. this.fireEvent("nodestore-datachange-end", this);
  1352. this.fireEvent("filter-set", this)
  1353. },
  1354. hideNodesBy : function(b, a) {
  1355. if (this.isFiltered()) {
  1356. throw new Error("Can't hide nodes of the filtered tree store")
  1357. }
  1358. var c = this;
  1359. a = a || this;
  1360. this.getRootNode().cascadeBy(function(d) {
  1361. d.hidden = b.call(a, d, c)
  1362. });
  1363. this.refreshNodeStoreContent()
  1364. },
  1365. showAllNodes : function() {
  1366. this.getRootNode().cascadeBy(function(a) {
  1367. a.hidden = a.data.hidden = false
  1368. });
  1369. this.refreshNodeStoreContent()
  1370. }
  1371. });
  1372. Ext.define("Sch.data.mixin.BufferableTreeStore", {
  1373. viewSize : 50,
  1374. buffered : false,
  1375. rangeStart : null,
  1376. rangeEnd : null,
  1377. initTreeBuffering : function() {
  1378. if (!this.buffered) {
  1379. return
  1380. }
  1381. var b = this;
  1382. var a = {
  1383. append : this.updateBufferedNodeStore,
  1384. insert : this.updateBufferedNodeStore,
  1385. remove : this.updateBufferedNodeStore,
  1386. move : this.updateBufferedNodeStore,
  1387. expand : this.updateBufferedNodeStore,
  1388. collapse : this.updateBufferedNodeStore,
  1389. sort : this.updateBufferedNodeStore,
  1390. scope : this,
  1391. buffer : 1
  1392. };
  1393. this.on(a);
  1394. this.on("root-fill-start", function() {
  1395. b.nodeStore.suspendEvents();
  1396. b.un(a);
  1397. b.nodeStore.setNode()
  1398. });
  1399. this.on("root-fill-end", function() {
  1400. b.nodeStore.resumeEvents();
  1401. b.on(a);
  1402. this.updateBufferedNodeStore()
  1403. })
  1404. },
  1405. updateBufferedNodeStore : function() {
  1406. this.refreshNodeStoreContent(true)
  1407. },
  1408. loadDataInNodeStore : function(a) {
  1409. if (!this.buffered) {
  1410. return false
  1411. }
  1412. var b = this.nodeStore;
  1413. b.totalCount = a.length;
  1414. if (!a.length) {
  1415. b.removeAll()
  1416. }
  1417. b.cachePage(a, 1);
  1418. this.guaranteeRange(this.rangeStart || 0, this.rangeEnd
  1419. || this.viewSize || 50);
  1420. return true
  1421. },
  1422. guaranteeRange : function(e, d) {
  1423. var b = this.viewSize || 50;
  1424. var f = this.nodeStore;
  1425. var a = f.getTotalCount();
  1426. if (a) {
  1427. var c = d - e + 1;
  1428. if (c < b && a >= c) {
  1429. d = e + b - 1
  1430. }
  1431. if (d >= a) {
  1432. e = a - (d - e);
  1433. d = a - 1;
  1434. e = Math.max(0, e)
  1435. }
  1436. f.guaranteeRange(e, d)
  1437. }
  1438. },
  1439. createNodeStore : function(a) {
  1440. var b = Ext.create(this.nodeStoreClassName
  1441. || "Ext.data.NodeStore", {
  1442. treeStore : a,
  1443. recursive : true,
  1444. rootVisible : this.rootVisible,
  1445. buffered : a.buffered,
  1446. purgePageCount : 0,
  1447. pageSize : 10000000000
  1448. });
  1449. if (a.buffered) {
  1450. this.mon(b, "guaranteedrange", function(d, e, c) {
  1451. this.rangeStart = e;
  1452. this.rangeEnd = c
  1453. }, this)
  1454. }
  1455. return b
  1456. }
  1457. });
  1458. Ext.define("Sch.data.ResourceStore", {
  1459. extend : "Ext.data.Store",
  1460. model : "Sch.model.Resource",
  1461. mixins : ["Sch.data.mixin.ResourceStore"]
  1462. });
  1463. Ext.define("Sch.data.TimeAxis", {
  1464. extend : "Ext.util.Observable",
  1465. requires : ["Ext.data.JsonStore", "Sch.util.Date"],
  1466. continuous : true,
  1467. autoAdjust : true,
  1468. constructor : function(a) {
  1469. Ext.apply(this, a);
  1470. this.originalContinuous = this.continuous;
  1471. this.addEvents("beforereconfigure", "reconfigure");
  1472. this.tickStore = new Ext.data.JsonStore({
  1473. fields : ["start", "end"]
  1474. });
  1475. this.tickStore.on("datachanged", function() {
  1476. this.fireEvent("reconfigure", this)
  1477. }, this);
  1478. this.callParent(arguments)
  1479. },
  1480. reconfigure : function(a) {
  1481. Ext.apply(this, a);
  1482. var c = this.tickStore, b = this.generateTicks(this.start, this.end,
  1483. this.unit, this.increment || 1, this.mainUnit);
  1484. if (this.fireEvent("beforereconfigure", this, this.start, this.end) !== false) {
  1485. c.suspendEvents(true);
  1486. c.loadData(b);
  1487. if (c.getCount() === 0) {
  1488. Ext.Error
  1489. .raise("Invalid time axis configuration or filter, please check your input data.")
  1490. }
  1491. c.resumeEvents()
  1492. }
  1493. },
  1494. setTimeSpan : function(b, a) {
  1495. this.reconfigure({
  1496. start : b,
  1497. end : a
  1498. })
  1499. },
  1500. filterBy : function(b, a) {
  1501. this.continuous = false;
  1502. a = a || this;
  1503. var c = this.tickStore;
  1504. c.clearFilter(true);
  1505. c.suspendEvents(true);
  1506. c.filter([{
  1507. filterFn : function(e, d) {
  1508. return b.call(a, e.data, d)
  1509. }
  1510. }]);
  1511. if (c.getCount() === 0) {
  1512. Ext.Error
  1513. .raise("Invalid time axis filter - no columns passed through the filter. Please check your filter method.");
  1514. this.clearFilter()
  1515. }
  1516. c.resumeEvents()
  1517. },
  1518. isContinuous : function() {
  1519. return this.continuous && !this.tickStore.isFiltered()
  1520. },
  1521. clearFilter : function() {
  1522. this.continuous = this.originalContinuous;
  1523. this.tickStore.clearFilter()
  1524. },
  1525. generateTicks : function(a, d, g, i) {
  1526. var h = [], f, b = Sch.util.Date, e = 0;
  1527. g = g || this.unit;
  1528. i = i || this.increment;
  1529. if (this.autoAdjust) {
  1530. a = this.floorDate(a || this.getStart(), false);
  1531. d = this.ceilDate(d || b.add(a, this.mainUnit, this.defaultSpan),
  1532. false)
  1533. }
  1534. while (a < d) {
  1535. f = this.getNext(a, g, i);
  1536. if (g === b.HOUR && i > 1 && h.length > 0 && e === 0) {
  1537. var c = h[h.length - 1];
  1538. e = ((c.start.getHours() + i) % 24) - c.end.getHours();
  1539. if (e !== 0) {
  1540. f = b.add(f, b.HOUR, e)
  1541. }
  1542. }
  1543. h.push({
  1544. start : a,
  1545. end : f
  1546. });
  1547. a = f
  1548. }
  1549. return h
  1550. },
  1551. getTickFromDate : function(c) {
  1552. if (this.getStart() > c || this.getEnd() < c) {
  1553. return -1
  1554. }
  1555. var f = this.tickStore.getRange(), e, a, d, b;
  1556. for (d = 0, b = f.length; d < b; d++) {
  1557. a = f[d].data.end;
  1558. if (c <= a) {
  1559. e = f[d].data.start;
  1560. return d + (c > e ? (c - e) / (a - e) : 0)
  1561. }
  1562. }
  1563. return -1
  1564. },
  1565. getDateFromTick : function(d, f) {
  1566. var g = this.tickStore.getCount();
  1567. if (d === g) {
  1568. return this.getEnd()
  1569. }
  1570. var a = Math.floor(d), e = d - a, c = this.getAt(a);
  1571. var b = Sch.util.Date.add(c.start, Sch.util.Date.MILLI, e
  1572. * (c.end - c.start));
  1573. if (f) {
  1574. b = this[f + "Date"](b)
  1575. }
  1576. return b
  1577. },
  1578. getAt : function(a) {
  1579. return this.tickStore.getAt(a).data
  1580. },
  1581. getCount : function() {
  1582. return this.tickStore.getCount()
  1583. },
  1584. getTicks : function() {
  1585. var a = [];
  1586. this.tickStore.each(function(b) {
  1587. a.push(b.data)
  1588. });
  1589. return a
  1590. },
  1591. getStart : function() {
  1592. var a = this.tickStore.first();
  1593. if (a) {
  1594. return Ext.Date.clone(a.data.start)
  1595. }
  1596. return null
  1597. },
  1598. getEnd : function() {
  1599. var a = this.tickStore.last();
  1600. if (a) {
  1601. return Ext.Date.clone(a.data.end)
  1602. }
  1603. return null
  1604. },
  1605. roundDate : function(r) {
  1606. var l = Ext.Date.clone(r), b = this.getStart(), s = this.resolutionIncrement;
  1607. switch (this.resolutionUnit) {
  1608. case Sch.util.Date.MILLI :
  1609. var e = Sch.util.Date.getDurationInMilliseconds(b, l), d = Math
  1610. .round(e / s)
  1611. * s;
  1612. l = Sch.util.Date.add(b, Sch.util.Date.MILLI, d);
  1613. break;
  1614. case Sch.util.Date.SECOND :
  1615. var i = Sch.util.Date.getDurationInSeconds(b, l), q = Math
  1616. .round(i / s)
  1617. * s;
  1618. l = Sch.util.Date.add(b, Sch.util.Date.MILLI, q * 1000);
  1619. break;
  1620. case Sch.util.Date.MINUTE :
  1621. var n = Sch.util.Date.getDurationInMinutes(b, l), a = Math
  1622. .round(n / s)
  1623. * s;
  1624. l = Sch.util.Date.add(b, Sch.util.Date.SECOND, a * 60);
  1625. break;
  1626. case Sch.util.Date.HOUR :
  1627. var m = Sch.util.Date.getDurationInHours(this.getStart(), l), j = Math
  1628. .round(m / s)
  1629. * s;
  1630. l = Sch.util.Date.add(b, Sch.util.Date.MINUTE, j * 60);
  1631. break;
  1632. case Sch.util.Date.DAY :
  1633. var c = Sch.util.Date.getDurationInDays(b, l), f = Math.round(c
  1634. / s)
  1635. * s;
  1636. l = Sch.util.Date.add(b, Sch.util.Date.DAY, f);
  1637. break;
  1638. case Sch.util.Date.WEEK :
  1639. Ext.Date.clearTime(l);
  1640. var o = l.getDay() - this.weekStartDay, t;
  1641. if (o < 0) {
  1642. o = 7 + o
  1643. }
  1644. if (Math.round(o / 7) === 1) {
  1645. t = 7 - o
  1646. } else {
  1647. t = -o
  1648. }
  1649. l = Sch.util.Date.add(l, Sch.util.Date.DAY, t);
  1650. break;
  1651. case Sch.util.Date.MONTH :
  1652. var p = Sch.util.Date.getDurationInMonths(b, l)
  1653. + (l.getDate() / Ext.Date.getDaysInMonth(l)), h = Math
  1654. .round(p / s)
  1655. * s;
  1656. l = Sch.util.Date.add(b, Sch.util.Date.MONTH, h);
  1657. break;
  1658. case Sch.util.Date.QUARTER :
  1659. Ext.Date.clearTime(l);
  1660. l.setDate(1);
  1661. l = Sch.util.Date.add(l, Sch.util.Date.MONTH, 3
  1662. - (l.getMonth() % 3));
  1663. break;
  1664. case Sch.util.Date.YEAR :
  1665. var k = Sch.util.Date.getDurationInYears(b, l), g = Math
  1666. .round(k / s)
  1667. * s;
  1668. l = Sch.util.Date.add(b, Sch.util.Date.YEAR, g);
  1669. break
  1670. }
  1671. return l
  1672. },
  1673. floorDate : function(t, d, v) {
  1674. d = d !== false;
  1675. var n = Ext.Date.clone(t), b = d ? this.getStart() : null, u = this.resolutionIncrement, k;
  1676. if (v) {
  1677. k = v
  1678. } else {
  1679. k = d ? this.resolutionUnit : this.mainUnit
  1680. }
  1681. switch (k) {
  1682. case Sch.util.Date.MILLI :
  1683. if (d) {
  1684. var f = Sch.util.Date.getDurationInMilliseconds(b, n), e = Math
  1685. .floor(f / u)
  1686. * u;
  1687. n = Sch.util.Date.add(b, Sch.util.Date.MILLI, e)
  1688. }
  1689. break;
  1690. case Sch.util.Date.SECOND :
  1691. if (d) {
  1692. var j = Sch.util.Date.getDurationInSeconds(b, n), s = Math
  1693. .floor(j / u)
  1694. * u;
  1695. n = Sch.util.Date.add(b, Sch.util.Date.MILLI, s * 1000)
  1696. } else {
  1697. n.setMilliseconds(0)
  1698. }
  1699. break;
  1700. case Sch.util.Date.MINUTE :
  1701. if (d) {
  1702. var p = Sch.util.Date.getDurationInMinutes(b, n), a = Math
  1703. .floor(p / u)
  1704. * u;
  1705. n = Sch.util.Date.add(b, Sch.util.Date.SECOND, a * 60)
  1706. } else {
  1707. n.setSeconds(0);
  1708. n.setMilliseconds(0)
  1709. }
  1710. break;
  1711. case Sch.util.Date.HOUR :
  1712. if (d) {
  1713. var o = Sch.util.Date
  1714. .getDurationInHours(this.getStart(), n), l = Math
  1715. .floor(o / u)
  1716. * u;
  1717. n = Sch.util.Date.add(b, Sch.util.Date.MINUTE, l * 60)
  1718. } else {
  1719. n.setMinutes(0);
  1720. n.setSeconds(0);
  1721. n.setMilliseconds(0)
  1722. }
  1723. break;
  1724. case Sch.util.Date.DAY :
  1725. if (d) {
  1726. var c = Sch.util.Date.getDurationInDays(b, n), g = Math
  1727. .floor(c / u)
  1728. * u;
  1729. n = Sch.util.Date.add(b, Sch.util.Date.DAY, g)
  1730. } else {
  1731. Ext.Date.clearTime(n)
  1732. }
  1733. break;
  1734. case Sch.util.Date.WEEK :
  1735. var r = n.getDay();
  1736. Ext.Date.clearTime(n);
  1737. if (r !== this.weekStartDay) {
  1738. n = Sch.util.Date.add(n, Sch.util.Date.DAY,
  1739. -(r > this.weekStartDay
  1740. ? (r - this.weekStartDay)
  1741. : (7 - r - this.weekStartDay)))
  1742. }
  1743. break;
  1744. case Sch.util.Date.MONTH :
  1745. if (d) {
  1746. var q = Sch.util.Date.getDurationInMonths(b, n), i = Math
  1747. .floor(q / u)
  1748. * u;
  1749. n = Sch.util.Date.add(b, Sch.util.Date.MONTH, i)
  1750. } else {
  1751. Ext.Date.clearTime(n);
  1752. n.setDate(1)
  1753. }
  1754. break;
  1755. case Sch.util.Date.QUARTER :
  1756. Ext.Date.clearTime(n);
  1757. n.setDate(1);
  1758. n = Sch.util.Date.add(n, Sch.util.Date.MONTH,
  1759. -(n.getMonth() % 3));
  1760. break;
  1761. case Sch.util.Date.YEAR :
  1762. if (d) {
  1763. var m = Sch.util.Date.getDurationInYears(b, n), h = Math
  1764. .floor(m / u)
  1765. * u;
  1766. n = Sch.util.Date.add(b, Sch.util.Date.YEAR, h)
  1767. } else {
  1768. n = new Date(t.getFullYear(), 0, 1)
  1769. }
  1770. break
  1771. }
  1772. return n
  1773. },
  1774. ceilDate : function(c, b, f) {
  1775. var e = Ext.Date.clone(c);
  1776. b = b !== false;
  1777. var a = b ? this.resolutionIncrement : 1, g = false, d;
  1778. if (f) {
  1779. d = f
  1780. } else {
  1781. d = b ? this.resolutionUnit : this.mainUnit
  1782. }
  1783. switch (d) {
  1784. case Sch.util.Date.DAY :
  1785. if (e.getMinutes() > 0 || e.getSeconds() > 0
  1786. || e.getMilliseconds() > 0) {
  1787. g = true
  1788. }
  1789. break;
  1790. case Sch.util.Date.WEEK :
  1791. Ext.Date.clearTime(e);
  1792. if (e.getDay() !== this.weekStartDay) {
  1793. g = true
  1794. }
  1795. break;
  1796. case Sch.util.Date.MONTH :
  1797. Ext.Date.clearTime(e);
  1798. if (e.getDate() !== 1) {
  1799. g = true
  1800. }
  1801. break;
  1802. case Sch.util.Date.QUARTER :
  1803. Ext.Date.clearTime(e);
  1804. if (e.getMonth() % 3 !== 0) {
  1805. g = true
  1806. }
  1807. break;
  1808. case Sch.util.Date.YEAR :
  1809. Ext.Date.clearTime(e);
  1810. if (e.getMonth() !== 0 && e.getDate() !== 1) {
  1811. g = true
  1812. }
  1813. break;
  1814. default :
  1815. break
  1816. }
  1817. if (g) {
  1818. return this.getNext(e, d, a)
  1819. } else {
  1820. return e
  1821. }
  1822. },
  1823. getNext : function(b, c, a) {
  1824. return Sch.util.Date.getNext(b, c, a, this.weekStartDay)
  1825. },
  1826. getResolution : function() {
  1827. return {
  1828. unit : this.resolutionUnit,
  1829. increment : this.resolutionIncrement
  1830. }
  1831. },
  1832. setResolution : function(b, a) {
  1833. this.resolutionUnit = b;
  1834. this.resolutionIncrement = a || 1
  1835. },
  1836. shiftNext : function(a) {
  1837. a = a || this.getShiftIncrement();
  1838. var b = this.getShiftUnit();
  1839. this.setTimeSpan(Sch.util.Date.add(this.getStart(), b, a),
  1840. Sch.util.Date.add(this.getEnd(), b, a))
  1841. },
  1842. shiftPrevious : function(a) {
  1843. a = -(a || this.getShiftIncrement());
  1844. var b = this.getShiftUnit();
  1845. this.setTimeSpan(Sch.util.Date.add(this.getStart(), b, a),
  1846. Sch.util.Date.add(this.getEnd(), b, a))
  1847. },
  1848. getShiftUnit : function() {
  1849. return this.shiftUnit || this.getMainUnit()
  1850. },
  1851. getShiftIncrement : function() {
  1852. return this.shiftIncrement || 1
  1853. },
  1854. getUnit : function() {
  1855. return this.unit
  1856. },
  1857. getIncrement : function() {
  1858. return this.increment
  1859. },
  1860. timeSpanInAxis : function(b, a) {
  1861. if (this.continuous) {
  1862. return Sch.util.Date.intersectSpans(b, a, this.getStart(), this
  1863. .getEnd())
  1864. } else {
  1865. return (b < this.getStart() && a > this.getEnd())
  1866. || this.getTickFromDate(b) !== this.getTickFromDate(a)
  1867. }
  1868. },
  1869. forEachInterval : function(b, a, c) {
  1870. c = c || this;
  1871. if (b === "top" || (b === "middle" && this.headerConfig.bottom)) {
  1872. this.forEachAuxInterval(b, a, c)
  1873. } else {
  1874. this.tickStore.each(function(e, d) {
  1875. return a.call(c, e.data.start, e.data.end, d)
  1876. })
  1877. }
  1878. },
  1879. forEachMainInterval : function(a, b) {
  1880. this.forEachInterval("middle", a, b)
  1881. },
  1882. forEachAuxInterval : function(b, a, f) {
  1883. f = f || this;
  1884. var c = this.getEnd(), g = this.getStart(), e = 0, d;
  1885. while (g < c) {
  1886. d = Sch.util.Date.min(this.getNext(g, this.headerConfig[b].unit,
  1887. this.headerConfig[b].increment || 1), c);
  1888. a.call(f, g, d, e);
  1889. g = d;
  1890. e++
  1891. }
  1892. }
  1893. });
  1894. Ext.define("Sch.preset.Manager", {
  1895. extend : "Ext.util.MixedCollection",
  1896. requires : ["Sch.util.Date", "Sch.util.HeaderRenderers"],
  1897. singleton : true,
  1898. constructor : function() {
  1899. this.callParent(arguments);
  1900. this.registerDefaults()
  1901. },
  1902. registerPreset : function(b, a) {
  1903. if (a) {
  1904. var c = a.headerConfig;
  1905. var d = Sch.util.Date;
  1906. for (var e in c) {
  1907. if (c.hasOwnProperty(e)) {
  1908. if (d[c[e].unit]) {
  1909. c[e].unit = d[c[e].unit.toUpperCase()]
  1910. }
  1911. }
  1912. }
  1913. if (!a.timeColumnWidth) {
  1914. a.timeColumnWidth = 50
  1915. }
  1916. if (a.timeResolution && d[a.timeResolution.unit]) {
  1917. a.timeResolution.unit = d[a.timeResolution.unit
  1918. .toUpperCase()]
  1919. }
  1920. if (a.shiftUnit && d[a.shiftUnit]) {
  1921. a.shiftUnit = d[a.shiftUnit.toUpperCase()]
  1922. }
  1923. }
  1924. if (this.isValidPreset(a)) {
  1925. if (this.containsKey(b)) {
  1926. this.removeAtKey(b)
  1927. }
  1928. this.add(b, a)
  1929. } else {
  1930. throw "Invalid preset, please check your configuration"
  1931. }
  1932. },
  1933. isValidPreset : function(a) {
  1934. var d = Sch.util.Date, b = true, c = Sch.util.Date.units;
  1935. for (var e in a.headerConfig) {
  1936. if (a.headerConfig.hasOwnProperty(e)) {
  1937. b = b
  1938. && Ext.Array.indexOf(c, a.headerConfig[e].unit) >= 0
  1939. }
  1940. }
  1941. if (a.timeResolution) {
  1942. b = b && Ext.Array.indexOf(c, a.timeResolution.unit) >= 0
  1943. }
  1944. if (a.shiftUnit) {
  1945. b = b && Ext.Array.indexOf(c, a.shiftUnit) >= 0
  1946. }
  1947. return b
  1948. },
  1949. getPreset : function(a) {
  1950. return this.get(a)
  1951. },
  1952. deletePreset : function(a) {
  1953. this.removeAtKey(a)
  1954. },
  1955. registerDefaults : function() {
  1956. var b = this, a = this.defaultPresets;
  1957. for (var c in a) {
  1958. b.registerPreset(c, a[c])
  1959. }
  1960. },
  1961. defaultPresets : {
  1962. minuteAndHour : {
  1963. timeColumnWidth : 100,
  1964. rowHeight : 24,
  1965. resourceColumnWidth : 100,
  1966. displayDateFormat : "G:i",
  1967. shiftIncrement : 1,
  1968. shiftUnit : "HOUR",
  1969. defaultSpan : 24,
  1970. timeResolution : {
  1971. unit : "MINUTE",
  1972. increment : 30
  1973. },
  1974. headerConfig : {
  1975. middle : {
  1976. unit : "MINUTE",
  1977. increment : "30",
  1978. dateFormat : "i"
  1979. },
  1980. top : {
  1981. unit : "HOUR",
  1982. dateFormat : "D, GA/m"
  1983. }
  1984. }
  1985. },
  1986. hourAndDay : {
  1987. timeColumnWidth : 60,
  1988. rowHeight : 24,
  1989. resourceColumnWidth : 100,
  1990. displayDateFormat : "G:i",
  1991. shiftIncrement : 1,
  1992. shiftUnit : "DAY",
  1993. defaultSpan : 24,
  1994. timeResolution : {
  1995. unit : "MINUTE",
  1996. increment : 30
  1997. },
  1998. headerConfig : {
  1999. middle : {
  2000. unit : "HOUR",
  2001. dateFormat : "G:i"
  2002. },
  2003. top : {
  2004. unit : "DAY",
  2005. dateFormat : "D d/m"
  2006. }
  2007. }
  2008. },
  2009. dayAndWeek : {
  2010. timeColumnWidth : 100,
  2011. rowHeight : 24,
  2012. resourceColumnWidth : 100,
  2013. displayDateFormat : "Y-m-d G:i",
  2014. shiftUnit : "DAY",
  2015. shiftIncrement : 1,
  2016. defaultSpan : 5,
  2017. timeResolution : {
  2018. unit : "HOUR",
  2019. increment : 1
  2020. },
  2021. headerConfig : {
  2022. middle : {
  2023. unit : "DAY",
  2024. dateFormat : "D d M"
  2025. },
  2026. top : {
  2027. unit : "WEEK",
  2028. dateFormat : "W M Y",
  2029. renderer : function(c, b, a) {
  2030. return Sch.util.Date.getShortNameOfUnit("WEEK")
  2031. + "." + Ext.Date.format(c, "W M Y")
  2032. }
  2033. }
  2034. }
  2035. },
  2036. weekAndDay : {
  2037. timeColumnWidth : 100,
  2038. rowHeight : 24,
  2039. resourceColumnWidth : 100,
  2040. displayDateFormat : "Y-m-d",
  2041. shiftUnit : "WEEK",
  2042. shiftIncrement : 1,
  2043. defaultSpan : 1,
  2044. timeResolution : {
  2045. unit : "DAY",
  2046. increment : 1
  2047. },
  2048. headerConfig : {
  2049. bottom : {
  2050. unit : "DAY",
  2051. increment : 1,
  2052. dateFormat : "d/m"
  2053. },
  2054. middle : {
  2055. unit : "WEEK",
  2056. dateFormat : "D d M",
  2057. align : "left"
  2058. }
  2059. }
  2060. },
  2061. weekAndMonth : {
  2062. timeColumnWidth : 100,
  2063. rowHeight : 24,
  2064. resourceColumnWidth : 100,
  2065. displayDateFormat : "Y-m-d",
  2066. shiftUnit : "WEEK",
  2067. shiftIncrement : 5,
  2068. defaultSpan : 6,
  2069. timeResolution : {
  2070. unit : "DAY",
  2071. increment : 1
  2072. },
  2073. headerConfig : {
  2074. middle : {
  2075. unit : "WEEK",
  2076. renderer : function(c, b, a) {
  2077. a.align = "left";
  2078. return Ext.Date.format(c, "d M")
  2079. }
  2080. },
  2081. top : {
  2082. unit : "MONTH",
  2083. dateFormat : "M Y"
  2084. }
  2085. }
  2086. },
  2087. monthAndYear : {
  2088. timeColumnWidth : 110,
  2089. rowHeight : 24,
  2090. resourceColumnWidth : 100,
  2091. displayDateFormat : "Y-m-d",
  2092. shiftIncrement : 3,
  2093. shiftUnit : "MONTH",
  2094. defaultSpan : 12,
  2095. timeResolution : {
  2096. unit : "DAY",
  2097. increment : 1
  2098. },
  2099. headerConfig : {
  2100. middle : {
  2101. unit : "MONTH",
  2102. dateFormat : "M Y"
  2103. },
  2104. top : {
  2105. unit : "YEAR",
  2106. dateFormat : "Y"
  2107. }
  2108. }
  2109. },
  2110. year : {
  2111. timeColumnWidth : 100,
  2112. rowHeight : 24,
  2113. resourceColumnWidth : 100,
  2114. displayDateFormat : "Y-m-d",
  2115. shiftUnit : "YEAR",
  2116. shiftIncrement : 1,
  2117. defaultSpan : 1,
  2118. timeResolution : {
  2119. unit : "MONTH",
  2120. increment : 1
  2121. },
  2122. headerConfig : {
  2123. bottom : {
  2124. unit : "QUARTER",
  2125. renderer : function(c, b, a) {
  2126. return Ext.String.format(Sch.util.Date
  2127. .getShortNameOfUnit("QUARTER")
  2128. .toUpperCase()
  2129. + "{0}", Math.floor(c
  2130. .getMonth()
  2131. / 3)
  2132. + 1)
  2133. }
  2134. },
  2135. middle : {
  2136. unit : "YEAR",
  2137. dateFormat : "Y"
  2138. }
  2139. }
  2140. },
  2141. weekAndDayLetter : {
  2142. timeColumnWidth : 20,
  2143. rowHeight : 24,
  2144. resourceColumnWidth : 100,
  2145. displayDateFormat : "Y-m-d",
  2146. shiftUnit : "WEEK",
  2147. shiftIncrement : 1,
  2148. defaultSpan : 10,
  2149. timeResolution : {
  2150. unit : "DAY",
  2151. increment : 1
  2152. },
  2153. headerConfig : {
  2154. bottom : {
  2155. unit : "DAY",
  2156. increment : 1,
  2157. renderer : function(a) {
  2158. return Ext.Date.dayNames[a.getDay()].substring(
  2159. 0, 1)
  2160. }
  2161. },
  2162. middle : {
  2163. unit : "WEEK",
  2164. dateFormat : "D d M Y",
  2165. align : "left"
  2166. }
  2167. }
  2168. },
  2169. weekDateAndMonth : {
  2170. timeColumnWidth : 30,
  2171. rowHeight : 24,
  2172. resourceColumnWidth : 100,
  2173. displayDateFormat : "Y-m-d",
  2174. shiftUnit : "WEEK",
  2175. shiftIncrement : 1,
  2176. defaultSpan : 10,
  2177. timeResolution : {
  2178. unit : "DAY",
  2179. increment : 1
  2180. },
  2181. headerConfig : {
  2182. middle : {
  2183. unit : "WEEK",
  2184. dateFormat : "d"
  2185. },
  2186. top : {
  2187. unit : "MONTH",
  2188. dateFormat : "Y F",
  2189. align : "left"
  2190. }
  2191. }
  2192. }
  2193. }
  2194. });
  2195. Ext.define("Sch.feature.AbstractTimeSpan", {
  2196. extend : "Ext.AbstractPlugin",
  2197. lockableScope : "normal",
  2198. schedulerView : null,
  2199. timeAxis : null,
  2200. containerEl : null,
  2201. expandToFitView : false,
  2202. disabled : false,
  2203. cls : null,
  2204. template : null,
  2205. store : null,
  2206. renderElementsBuffered : false,
  2207. renderDelay : 15,
  2208. constructor : function(a) {
  2209. this.uniqueCls = this.uniqueCls || ("sch-timespangroup-" + Ext.id());
  2210. Ext.apply(this, a)
  2211. },
  2212. setDisabled : function(a) {
  2213. if (a) {
  2214. this.removeElements()
  2215. }
  2216. this.disabled = a
  2217. },
  2218. getElements : function() {
  2219. if (this.containerEl) {
  2220. return this.containerEl.select("." + this.uniqueCls)
  2221. }
  2222. return null
  2223. },
  2224. removeElements : function() {
  2225. var a = this.getElements();
  2226. if (a) {
  2227. a.remove()
  2228. }
  2229. },
  2230. init : function(a) {
  2231. this.timeAxis = a.getTimeAxis();
  2232. this.schedulerView = a.getSchedulingView();
  2233. if (!this.store) {
  2234. Ext.Error.raise("Error: You must define a store for this plugin")
  2235. }
  2236. this.schedulerView.on({
  2237. afterrender : this.onAfterRender,
  2238. destroy : this.onDestroy,
  2239. scope : this
  2240. })
  2241. },
  2242. onAfterRender : function(b) {
  2243. var a = this.schedulerView;
  2244. this.containerEl = a.el;
  2245. a.mon(this.store, {
  2246. load : this.renderElements,
  2247. datachanged : this.renderElements,
  2248. clear : this.renderElements,
  2249. add : this.renderElements,
  2250. remove : this.renderElements,
  2251. update : this.refreshSingle,
  2252. scope : this
  2253. });
  2254. if (Ext.data.NodeStore && a.store instanceof Ext.data.NodeStore) {
  2255. if (a.animate) {
  2256. } else {
  2257. a.mon(a.store, {
  2258. expand : this.renderElements,
  2259. collapse : this.renderElements,
  2260. scope : this
  2261. })
  2262. }
  2263. }
  2264. a.on({
  2265. refresh : this.renderElements,
  2266. itemadd : this.renderElements,
  2267. itemremove : this.renderElements,
  2268. itemupdate : this.renderElements,
  2269. groupexpand : this.renderElements,
  2270. groupcollapse : this.renderElements,
  2271. columnwidthchange : this.renderElements,
  2272. resize : this.renderElements,
  2273. scope : this
  2274. });
  2275. a.headerCt.on({
  2276. add : this.renderElements,
  2277. remove : this.renderElements,
  2278. scope : this
  2279. });
  2280. a.ownerCt.up("panel").on({
  2281. viewchange : this.renderElements,
  2282. orientationchange : this.renderElements,
  2283. scope : this
  2284. });
  2285. this.renderElements()
  2286. },
  2287. renderElements : function() {
  2288. if (this.renderElementsBuffered || this.disabled
  2289. || this.schedulerView.headerCt.getColumnCount() === 0) {
  2290. return
  2291. }
  2292. this.renderElementsBuffered = true;
  2293. Ext.Function.defer(this.renderElementsInternal, this.renderDelay, this)
  2294. },
  2295. renderElementsInternal : function() {
  2296. this.renderElementsBuffered = false;
  2297. if (this.disabled || this.schedulerView.isDestroyed
  2298. || this.schedulerView.headerCt.getColumnCount() === 0) {
  2299. return
  2300. }
  2301. this.removeElements();
  2302. Ext.core.DomHelper.insertHtml("afterBegin", this.containerEl.dom, this
  2303. .generateMarkup())
  2304. },
  2305. generateMarkup : function(b) {
  2306. var d = this.timeAxis.getStart(), a = this.timeAxis.getEnd(), c = this
  2307. .getElementData(d, a, null, b);
  2308. return this.template.apply(c)
  2309. },
  2310. getElementData : function(b, a) {
  2311. throw "Abstract method call"
  2312. },
  2313. onDestroy : function() {
  2314. if (this.store.autoDestroy) {
  2315. this.store.destroy()
  2316. }
  2317. },
  2318. refreshSingle : function(c, b) {
  2319. var e = Ext.get(this.uniqueCls + "-" + b.internalId);
  2320. if (e) {
  2321. var g = this.timeAxis.getStart(), a = this.timeAxis.getEnd(), f = this
  2322. .getElementData(g, a, [b])[0], d = b.clsField || "Cls";
  2323. if (f) {
  2324. e.dom.className = this.cls + " " + this.uniqueCls + " "
  2325. + (f[d] || "");
  2326. e.setTop(f.top);
  2327. e.setLeft(f.left);
  2328. e.setSize(f.width, f.height)
  2329. } else {
  2330. Ext.destroy(e)
  2331. }
  2332. } else {
  2333. this.renderElements()
  2334. }
  2335. }
  2336. });
  2337. Ext.define("Sch.plugin.Lines", {
  2338. extend : "Sch.feature.AbstractTimeSpan",
  2339. cls : "sch-timeline",
  2340. showTip : true,
  2341. innerTpl : null,
  2342. init : function(b) {
  2343. this.callParent(arguments);
  2344. var a = this.schedulerView;
  2345. if (Ext.isString(this.innerTpl)) {
  2346. this.innerTpl = new Ext.XTemplate(this.innerTpl)
  2347. }
  2348. var c = this.innerTpl;
  2349. if (!this.template) {
  2350. this.template = new Ext.XTemplate(
  2351. '<tpl for=".">',
  2352. '<div id="'
  2353. + this.uniqueCls
  2354. + '-{id}"'
  2355. + (this.showTip
  2356. ? 'title="{[this.getTipText(values)]}" '
  2357. : "")
  2358. + 'class="'
  2359. + this.cls
  2360. + " "
  2361. + this.uniqueCls
  2362. + ' {Cls}" style="left:{left}px;top:{top}px;height:{height}px;width:{width}px">'
  2363. + (c ? "{[this.renderInner(values)]}" : "")
  2364. + "</div>", "</tpl>", {
  2365. getTipText : function(d) {
  2366. return a.getFormattedDate(d.Date) + " "
  2367. + (d.Text || "")
  2368. },
  2369. renderInner : function(d) {
  2370. return c.apply(d)
  2371. }
  2372. })
  2373. }
  2374. },
  2375. getElementData : function(j, m, c) {
  2376. var n = this.store, h = this.schedulerView, e = c || n.getRange(), g = [], a, b, k;
  2377. for (var f = 0, d = e.length; f < d; f++) {
  2378. a = e[f];
  2379. b = a.get("Date");
  2380. if (b && Sch.util.Date.betweenLesser(b, j, m)) {
  2381. k = h.getTimeSpanRegion(b, null, this.expandToFitView);
  2382. g[g.length] = Ext.apply({
  2383. id : a.internalId,
  2384. left : k.left,
  2385. top : k.top,
  2386. width : 1,
  2387. height : k.bottom - k.top
  2388. }, a.data)
  2389. }
  2390. }
  2391. return g
  2392. }
  2393. });
  2394. Ext.define("Sch.plugin.Zones", {
  2395. extend : "Sch.feature.AbstractTimeSpan",
  2396. innerTpl : null,
  2397. requires : ["Sch.model.Range"],
  2398. cls : "sch-zone",
  2399. init : function(a) {
  2400. if (Ext.isString(this.innerTpl)) {
  2401. this.innerTpl = new Ext.XTemplate(this.innerTpl)
  2402. }
  2403. var b = this.innerTpl;
  2404. if (!this.template) {
  2405. this.template = new Ext.XTemplate(
  2406. '<tpl for="."><div id="'
  2407. + this.uniqueCls
  2408. + '-{id}" class="'
  2409. + this.cls
  2410. + " "
  2411. + this.uniqueCls
  2412. + ' {Cls}" style="left:{left}px;top:{top}px;height:{height}px;width:{width}px;{style}">'
  2413. + (b ? "{[this.renderInner(values)]}" : "")
  2414. + "</div></tpl>", {
  2415. renderInner : function(c) {
  2416. return b.apply(c)
  2417. }
  2418. })
  2419. }
  2420. this.callParent(arguments)
  2421. },
  2422. getElementData : function(k, o, d, p) {
  2423. var q = this.store, j = this.schedulerView, f = d || q.getRange(), h = [], a, n, c, m;
  2424. for (var g = 0, e = f.length; g < e; g++) {
  2425. a = f[g];
  2426. n = a.getStartDate();
  2427. c = a.getEndDate();
  2428. if (n && c && Sch.util.Date.intersectSpans(n, c, k, o)) {
  2429. m = j.getTimeSpanRegion(Sch.util.Date.max(n, k), Sch.util.Date
  2430. .min(c, o), this.expandToFitView);
  2431. var b = m.right - m.left;
  2432. h[h.length] = Ext.apply({
  2433. id : a.internalId,
  2434. left : m.left,
  2435. top : m.top,
  2436. width : p ? 0 : b,
  2437. height : m.bottom - m.top,
  2438. style : p ? ("border-left-width:" + b + "px") : "",
  2439. Cls : a.getCls()
  2440. }, a.data)
  2441. }
  2442. }
  2443. return h
  2444. }
  2445. });
  2446. Ext.define("Sch.plugin.Pan", {
  2447. alias : "plugin.pan",
  2448. extend : "Ext.AbstractPlugin",
  2449. lockableScope : "normal",
  2450. enableVerticalPan : true,
  2451. panel : null,
  2452. constructor : function(a) {
  2453. Ext.apply(this, a)
  2454. },
  2455. init : function(a) {
  2456. this.panel = a.normalGrid || a;
  2457. this.view = a.getSchedulingView();
  2458. this.view.on("afterrender", this.onRender, this)
  2459. },
  2460. onRender : function(a) {
  2461. this.view.el.on("mousedown", this.onMouseDown, this)
  2462. },
  2463. onMouseDown : function(b, a) {
  2464. if (b.getTarget("." + this.view.timeCellCls, 10)
  2465. && !b.getTarget(this.view.eventSelector)) {
  2466. this.mouseX = b.getPageX();
  2467. this.mouseY = b.getPageY();
  2468. Ext.getBody().on("mousemove", this.onMouseMove, this);
  2469. Ext.getDoc().on("mouseup", this.onMouseUp, this);
  2470. if (Ext.isIE || Ext.isGecko) {
  2471. Ext.getBody().on("mouseenter", this.onMouseUp, this)
  2472. }
  2473. b.stopEvent()
  2474. }
  2475. },
  2476. onMouseMove : function(d) {
  2477. d.stopEvent();
  2478. var a = d.getPageX(), f = d.getPageY(), c = a - this.mouseX, b = f
  2479. - this.mouseY;
  2480. this.panel.scrollByDeltaX(-c);
  2481. this.mouseX = a;
  2482. this.mouseY = f;
  2483. if (this.enableVerticalPan) {
  2484. this.panel.scrollByDeltaY(-b)
  2485. }
  2486. },
  2487. onMouseUp : function(a) {
  2488. Ext.getBody().un("mousemove", this.onMouseMove, this);
  2489. Ext.getDoc().un("mouseup", this.onMouseUp, this);
  2490. if (Ext.isIE || Ext.isGecko) {
  2491. Ext.getBody().un("mouseenter", this.onMouseUp, this)
  2492. }
  2493. }
  2494. });
  2495. Ext.define("Sch.view.Locking", {
  2496. extend : "Ext.grid.LockingView",
  2497. scheduleEventRelayRe : /^(schedule|event|beforeevent|afterevent|dragcreate|beforedragcreate|afterdragcreate|beforetooltipshow)/,
  2498. constructor : function(b) {
  2499. this.callParent(arguments);
  2500. var e = this, g = [], a = e.scheduleEventRelayRe, f = b.normal
  2501. .getView(), c = f.events, d;
  2502. for (d in c) {
  2503. if (c.hasOwnProperty(d) && a.test(d)) {
  2504. g.push(d)
  2505. }
  2506. }
  2507. e.relayEvents(f, g)
  2508. },
  2509. getElementFromEventRecord : function(a) {
  2510. return this.normal.getView().getElementFromEventRecord(a)
  2511. },
  2512. onClear : function() {
  2513. this.relayFn("onClear", arguments)
  2514. },
  2515. beginBulkUpdate : function() {
  2516. this.relayFn("beginBulkUpdate", arguments)
  2517. },
  2518. endBulkUpdate : function() {
  2519. this.relayFn("endBulkUpdate", arguments)
  2520. },
  2521. refreshKeepingScroll : function() {
  2522. this.locked.getView().refresh();
  2523. this.normal.getView().refreshKeepingScroll()
  2524. }
  2525. });
  2526. Ext.define("Sch.column.Time", {
  2527. extend : "Ext.grid.column.Column",
  2528. alias : "timecolumn",
  2529. draggable : false,
  2530. groupable : false,
  2531. hideable : false,
  2532. sortable : false,
  2533. fixed : true,
  2534. align : "center",
  2535. tdCls : "sch-timetd",
  2536. menuDisabled : true,
  2537. initComponent : function() {
  2538. this.addEvents("timeheaderdblclick");
  2539. this.enableBubble("timeheaderdblclick");
  2540. this.callParent()
  2541. },
  2542. initRenderData : function() {
  2543. var a = this;
  2544. a.renderData.headerCls = a.renderData.headerCls || a.headerCls;
  2545. return a.callParent(arguments)
  2546. },
  2547. onElDblClick : function(b, a) {
  2548. this.callParent(arguments);
  2549. this.fireEvent("timeheaderdblclick", this, this.startDate,
  2550. this.endDate, b)
  2551. }
  2552. }, function() {
  2553. Sch.column.Time.prototype.renderTpl = Sch.column.Time.prototype.renderTpl
  2554. .replace("column-header-inner",
  2555. "column-header-inner sch-timeheader {headerCls}")
  2556. });
  2557. Ext.define("Sch.column.timeAxis.Horizontal", {
  2558. extend : "Ext.grid.column.Column",
  2559. alias : "widget.timeaxiscolumn",
  2560. requires : ["Ext.Date", "Ext.XTemplate", "Sch.column.Time",
  2561. "Sch.preset.Manager"],
  2562. cls : "sch-timeaxiscolumn",
  2563. timeAxis : null,
  2564. renderTpl : '<div id="{id}-titleEl" class="'
  2565. + Ext.baseCSSPrefix
  2566. + 'column-header-inner"><span id="{id}-textEl" style="display:none" class="'
  2567. + Ext.baseCSSPrefix
  2568. + 'column-header-text"></span><tpl if="topHeaderCells">{topHeaderCells}</tpl><tpl if="middleHeaderCells">{middleHeaderCells}</tpl></div>{%this.renderContainer(out,values)%}',
  2569. headerRowTpl : '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}" class="sch-header-row sch-header-row-{position}"><thead><tr>{cells}</tr></thead></table>',
  2570. headerCellTpl : '<tpl for="."><td class="sch-column-header x-column-header {headerCls}" style="position : static; text-align: {align}; {style}" tabIndex="0" id="{headerId}" headerPosition="{position}" headerIndex="{index}"><div class="x-column-header-inner">{header}</div></td></tpl>',
  2571. columnConfig : {},
  2572. timeCellRenderer : null,
  2573. timeCellRendererScope : null,
  2574. columnWidth : null,
  2575. previousWidth : null,
  2576. previousHeight : null,
  2577. initComponent : function() {
  2578. if (!(this.headerRowTpl instanceof Ext.Template)) {
  2579. this.headerRowTpl = Ext.create("Ext.XTemplate", this.headerRowTpl)
  2580. }
  2581. if (!(this.headerCellTpl instanceof Ext.Template)) {
  2582. this.headerCellTpl = Ext
  2583. .create("Ext.XTemplate", this.headerCellTpl)
  2584. }
  2585. this.columns = [{}];
  2586. this.addEvents("timeheaderdblclick", "timeaxiscolumnreconfigured");
  2587. this.enableBubble("timeheaderdblclick");
  2588. this.stubForResizer = new Ext.Component({
  2589. isOnLeftEdge : function() {
  2590. return false
  2591. },
  2592. isOnRightEdge : function() {
  2593. return false
  2594. },
  2595. el : {
  2596. dom : {
  2597. style : {}
  2598. }
  2599. }
  2600. });
  2601. this.callParent(arguments);
  2602. this.onTimeAxisReconfigure();
  2603. this
  2604. .mon(this.timeAxis, "reconfigure", this.onTimeAxisReconfigure,
  2605. this)
  2606. },
  2607. getSchedulingView : function() {
  2608. return this.getOwnerHeaderCt().view
  2609. },
  2610. onTimeAxisReconfigure : function() {
  2611. var e = this.timeAxis, d = e.preset.timeColumnWidth, f = this.rendered
  2612. && this.getSchedulingView(), g = e.headerConfig, b = e
  2613. .getStart(), c = e.getEnd(), h = {
  2614. renderer : this.timeColumnRenderer,
  2615. scope : this,
  2616. width : this.rendered ? f.calculateTimeColumnWidth(d) : d
  2617. };
  2618. delete this.previousWidth;
  2619. delete this.previousHeight;
  2620. var j = this.columnConfig = this.createColumns(this.timeAxis, g, h);
  2621. Ext.suspendLayouts();
  2622. this.removeAll();
  2623. if (this.rendered) {
  2624. var a = this.el.child(".x-column-header-inner");
  2625. a.select("table").remove();
  2626. var i = this.initRenderData();
  2627. if (j.top) {
  2628. Ext.core.DomHelper.append(a, i.topHeaderCells)
  2629. }
  2630. if (j.middle) {
  2631. Ext.core.DomHelper.append(a, i.middleHeaderCells)
  2632. }
  2633. if (!j.top && !j.middle) {
  2634. this.addCls("sch-header-single-row")
  2635. } else {
  2636. this.removeCls("sch-header-single-row")
  2637. }
  2638. }
  2639. Ext.resumeLayouts();
  2640. this.add(j.bottom);
  2641. if (this.rendered) {
  2642. if (this.fireEvent("timeaxiscolumnreconfigured", this) !== false) {
  2643. f.refresh()
  2644. }
  2645. }
  2646. },
  2647. beforeRender : function() {
  2648. var a = this.columnConfig;
  2649. if (!a.middle && !a.top) {
  2650. this.addCls("sch-header-single-row")
  2651. }
  2652. this.callParent(arguments)
  2653. },
  2654. timeColumnRenderer : function(i, e, f, l, d, c, k) {
  2655. var a = "";
  2656. if (Ext.isIE) {
  2657. e.style += ";z-index:" + (this.items.getCount() - d)
  2658. }
  2659. if (this.timeCellRenderer) {
  2660. var h = this.timeAxis, b = h.getAt(d), g = b.start, j = b.end;
  2661. a = this.timeCellRenderer.call(this.timeCellRendererScope || this,
  2662. e, f, l, d, c, g, j)
  2663. }
  2664. return a
  2665. },
  2666. initRenderData : function() {
  2667. var a = this.columnConfig;
  2668. var c = a.top ? this.headerRowTpl.apply({
  2669. cells : this.headerCellTpl.apply(a.top),
  2670. position : "top",
  2671. tstyle : "border-top : 0; width : 100px"
  2672. }) : "";
  2673. var b = a.middle ? this.headerRowTpl.apply({
  2674. cells : this.headerCellTpl.apply(a.middle),
  2675. position : "middle",
  2676. tstyle : a.top
  2677. ? "width : 100px"
  2678. : "border-top : 0; width : 100px"
  2679. }) : "";
  2680. return Ext.apply(this.callParent(arguments), {
  2681. topHeaderCells : c,
  2682. middleHeaderCells : b
  2683. })
  2684. },
  2685. defaultRenderer : function(c, b, a) {
  2686. return Ext.Date.format(c, a)
  2687. },
  2688. createColumns : function(f, d, g) {
  2689. if (!f || !d) {
  2690. throw "Invalid parameters passed to createColumns"
  2691. }
  2692. var c = [], a = d.bottom || d.middle, h, e = this;
  2693. f.forEachInterval(d.bottom ? "bottom" : "middle", function(l, j, k) {
  2694. h = {
  2695. align : a.align || "center",
  2696. headerCls : "",
  2697. startDate : l,
  2698. endDate : j
  2699. };
  2700. if (a.renderer) {
  2701. h.header = a.renderer.call(a.scope || e, l, j, h, k)
  2702. } else {
  2703. h.header = e.defaultRenderer(l, j, a.dateFormat)
  2704. }
  2705. c[c.length] = Ext
  2706. .create("Sch.column.Time", Ext.apply(h, g))
  2707. });
  2708. var b = this.createHeaderRows(f, d);
  2709. return {
  2710. bottom : c,
  2711. middle : b.middle,
  2712. top : b.top
  2713. }
  2714. },
  2715. createHeaderRows : function(e, c) {
  2716. var d = {};
  2717. if (c.top) {
  2718. var a;
  2719. if (c.top.cellGenerator) {
  2720. a = c.top.cellGenerator.call(this, e.getStart(), e.getEnd())
  2721. } else {
  2722. a = this.createHeaderRow(e, c.top)
  2723. }
  2724. d.top = this.processHeaderRow(a, "top")
  2725. }
  2726. if (c.bottom) {
  2727. var b;
  2728. if (c.middle.cellGenerator) {
  2729. b = c.middle.cellGenerator.call(this, e.getStart(), e.getEnd())
  2730. } else {
  2731. b = this.createHeaderRow(e, c.middle)
  2732. }
  2733. d.middle = this.processHeaderRow(b, "middle")
  2734. }
  2735. return d
  2736. },
  2737. processHeaderRow : function(c, a) {
  2738. var b = this;
  2739. Ext.each(c, function(d, e) {
  2740. d.index = e;
  2741. d.position = a;
  2742. d.headerId = b.stubForResizer.id
  2743. });
  2744. return c
  2745. },
  2746. createHeaderRow : function(e, k) {
  2747. var n = [], l, a = e.getStart(), c = e.getEnd(), m = c - a, j = [], b = a, d = 0, f, g = k.align
  2748. || "center", h;
  2749. while (b < c) {
  2750. h = Sch.util.Date.min(e.getNext(b, k.unit, k.increment || 1), c);
  2751. l = {
  2752. align : g,
  2753. start : b,
  2754. end : h,
  2755. headerCls : ""
  2756. };
  2757. if (k.renderer) {
  2758. l.header = k.renderer.call(k.scope || this, b, h, l, d)
  2759. } else {
  2760. l.header = this.defaultRenderer(b, h, k.dateFormat, l, d)
  2761. }
  2762. n.push(l);
  2763. b = h;
  2764. d++
  2765. }
  2766. return n
  2767. },
  2768. afterLayout : function() {
  2769. delete this.columnWidth;
  2770. this.callParent(arguments);
  2771. var b = this.getWidth();
  2772. var g = this.getHeight();
  2773. if (b === this.previousWidth && g === this.previousHeight) {
  2774. return
  2775. }
  2776. this.previousWidth = b;
  2777. this.previousHeight = g;
  2778. var i = this.columnConfig;
  2779. var e = this;
  2780. var c = this.el;
  2781. var f = i.top;
  2782. var d = 0;
  2783. var a = 0;
  2784. if (f) {
  2785. c.select(".sch-header-row-top").setWidth(this.lastBox.width);
  2786. c.select(".sch-header-row-top td").each(function(l, m, j) {
  2787. var k = e.getHeaderGroupCellWidth(f[j].start, f[j].end);
  2788. l.setVisibilityMode(Ext.Element.DISPLAY);
  2789. if (k) {
  2790. d += k;
  2791. l.show();
  2792. l.setWidth(k)
  2793. } else {
  2794. l.hide()
  2795. }
  2796. })
  2797. }
  2798. var h = i.middle;
  2799. if (h) {
  2800. c.select(".sch-header-row-middle").setWidth(this.lastBox.width);
  2801. c.select(".sch-header-row-middle td").each(function(l, m, j) {
  2802. var k = e.getHeaderGroupCellWidth(h[j].start, h[j].end);
  2803. l.setVisibilityMode(Ext.Element.DISPLAY);
  2804. if (k) {
  2805. a += k;
  2806. l.show();
  2807. l.setWidth(k)
  2808. } else {
  2809. l.hide()
  2810. }
  2811. })
  2812. }
  2813. },
  2814. getHeaderGroupCellWidth : function(h, b) {
  2815. var e = this.timeAxis.unit, d = this.timeAxis.increment, c, g = Sch.util.Date
  2816. .getMeasuringUnit(e), a = Sch.util.Date.getDurationInUnit(h, b,
  2817. g), f = this.getSchedulingView();
  2818. if (this.timeAxis.isContinuous()) {
  2819. c = a * f.getSingleUnitInPixels(g)
  2820. } else {
  2821. c = f.getXYFromDate(b)[0] - f.getXYFromDate(h)[0]
  2822. }
  2823. return c
  2824. },
  2825. onElDblClick : function(d, f) {
  2826. this.callParent(arguments);
  2827. var e = d.getTarget(".sch-column-header");
  2828. if (e) {
  2829. var a = Ext.fly(e).getAttribute("headerPosition"), b = Ext.fly(e)
  2830. .getAttribute("headerIndex"), c = this.columnConfig[a][b];
  2831. this.fireEvent("timeheaderdblclick", this, c.start, c.end, d)
  2832. }
  2833. },
  2834. getTimeColumnWidth : function() {
  2835. if (this.columnWidth === null) {
  2836. this.columnWidth = this.items.get(0).getWidth()
  2837. }
  2838. return this.columnWidth
  2839. },
  2840. setTimeColumnWidth : function(a) {
  2841. this.suspendEvents();
  2842. this.items.each(function(b) {
  2843. b.setWidth(a)
  2844. });
  2845. this.resumeEvents()
  2846. }
  2847. });
  2848. Ext.define("Sch.column.timeAxis.HorizontalSingle", {
  2849. extend : "Sch.column.Time",
  2850. alias : "widget.singletimeaxiscolumn",
  2851. requires : ["Ext.Date", "Ext.XTemplate", "Sch.preset.Manager"],
  2852. cls : "sch-simple-timeaxis",
  2853. timeAxis : null,
  2854. trackHeaderOver : true,
  2855. compactCellWidthThreshold : 16,
  2856. renderTpl : '<div id="{id}-titleEl" class="'
  2857. + Ext.baseCSSPrefix
  2858. + 'column-header-inner"><span id="{id}-textEl" style="display:none" class="'
  2859. + Ext.baseCSSPrefix
  2860. + 'column-header-text"></span><tpl if="topHeaderCells">{topHeaderCells}</tpl><tpl if="middleHeaderCells">{middleHeaderCells}</tpl><tpl if="bottomHeaderCells">{bottomHeaderCells}</tpl></div>{%this.renderContainer(out,values)%}',
  2861. headerRowTpl : '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}" class="sch-header-row sch-header-row-{position}"><thead><tr><tpl for="cells"><td class="sch-column-header x-column-header {headerCls}" style="position : static; text-align: {align}; {style}" tabIndex="0" id="{headerId}" headerPosition="{parent.position}" headerIndex="{[xindex-1]}"><div class="sch-simple-timeheader">{header}</div></td></tpl></tr></thead></table>',
  2862. columnConfig : {},
  2863. columnWidth : null,
  2864. nbrTimeColumns : null,
  2865. initComponent : function() {
  2866. this.tdCls += " sch-singletimetd";
  2867. if (!(this.headerRowTpl instanceof Ext.Template)) {
  2868. this.headerRowTpl = Ext.create("Ext.XTemplate", this.headerRowTpl)
  2869. }
  2870. this.addEvents("timeheaderdblclick", "timeaxiscolumnreconfigured");
  2871. this.enableBubble("timeheaderdblclick");
  2872. this.callParent(arguments);
  2873. this.onTimeAxisReconfigure();
  2874. this
  2875. .mon(this.timeAxis, "reconfigure", this.onTimeAxisReconfigure,
  2876. this);
  2877. this.on("resize", this.refreshHeaderSizes, this);
  2878. this.ownHoverCls = this.hoverCls;
  2879. this.hoverCls = ""
  2880. },
  2881. getSchedulingView : function() {
  2882. return this.getOwnerHeaderCt().view
  2883. },
  2884. onTimeAxisReconfigure : function() {
  2885. var h = this.timeAxis, g = h.preset.timeColumnWidth, j = this.rendered
  2886. && this.getSchedulingView(), l = h.headerConfig, c = h
  2887. .getStart(), f = h.getEnd(), d = this.rendered ? j
  2888. .calculateTimeColumnWidth(g) : g;
  2889. var o = this.columnConfig = this.createHeaderRows(l);
  2890. var a = o.bottom || o.middle;
  2891. if (this.rendered) {
  2892. var e;
  2893. var b = this.el.child(".x-column-header-inner");
  2894. var i = b.dom;
  2895. var k = i.style.display;
  2896. var m = i.parentNode;
  2897. i.style.display = "none";
  2898. m.removeChild(i);
  2899. i.innerHTML = "";
  2900. var n = this.initRenderData();
  2901. if (o.top) {
  2902. e = Ext.core.DomHelper.append(b, n.topHeaderCells);
  2903. this.refreshHeaderRow("top", e)
  2904. }
  2905. if (o.middle) {
  2906. e = Ext.core.DomHelper.append(b, n.middleHeaderCells);
  2907. this.refreshHeaderRow("middle", e)
  2908. }
  2909. if (o.bottom) {
  2910. e = Ext.core.DomHelper.append(b, n.bottomHeaderCells);
  2911. this.refreshHeaderRow("bottom", e)
  2912. }
  2913. if (!o.top && !o.middle) {
  2914. this.addCls("sch-header-single-row")
  2915. } else {
  2916. this.removeCls("sch-header-single-row")
  2917. }
  2918. m.appendChild(i);
  2919. i.style.display = k;
  2920. if (d !== this.columnWidth || this.nbrTimeColumns !== a.length) {
  2921. this.nbrTimeColumns = a.length;
  2922. this.setTimeColumnWidth(d)
  2923. }
  2924. if (this.fireEvent("timeaxiscolumnreconfigured", this) !== false) {
  2925. j.refreshKeepingResourceScroll(true)
  2926. }
  2927. } else {
  2928. if (d !== this.columnWidth || this.nbrTimeColumns !== a.length) {
  2929. this.nbrTimeColumns = a.length;
  2930. this.setTimeColumnWidth(d)
  2931. }
  2932. }
  2933. },
  2934. beforeRender : function() {
  2935. var b = this, a = this.columnConfig;
  2936. if (!a.middle && !a.top) {
  2937. b.addCls("sch-header-single-row")
  2938. }
  2939. b.callParent(arguments)
  2940. },
  2941. afterRender : function() {
  2942. var a = this;
  2943. if (this.trackHeaderOver) {
  2944. a.el.on({
  2945. mousemove : a.highlightCell,
  2946. delegate : "div.sch-simple-timeheader",
  2947. scope : a
  2948. });
  2949. a.el.on({
  2950. mouseleave : a.clearHighlight,
  2951. scope : a
  2952. })
  2953. }
  2954. a.callParent(arguments)
  2955. },
  2956. initRenderData : function() {
  2957. var a = this.columnConfig;
  2958. var c = a.top ? this.headerRowTpl.apply({
  2959. cells : a.top,
  2960. position : "top",
  2961. tstyle : "border-top : 0; width : 100px"
  2962. }) : "";
  2963. var b = a.middle ? this.headerRowTpl.apply({
  2964. cells : a.middle,
  2965. position : "middle",
  2966. tstyle : a.top
  2967. ? "width : 100px"
  2968. : "border-top : 0; width : 100px"
  2969. }) : "";
  2970. var d = a.bottom ? this.headerRowTpl.apply({
  2971. cells : a.bottom,
  2972. position : "bottom",
  2973. tstyle : "width : 100px"
  2974. }) : "";
  2975. return Ext.apply(this.callParent(arguments), {
  2976. topHeaderCells : c,
  2977. middleHeaderCells : b,
  2978. bottomHeaderCells : d
  2979. })
  2980. },
  2981. defaultRenderer : function(c, b, a) {
  2982. return Ext.Date.format(c, a)
  2983. },
  2984. createHeaderRows : function(a) {
  2985. var b = {};
  2986. for (var c in a) {
  2987. if (a[c].cellGenerator) {
  2988. b[c] = a[c].cellGenerator.call(this, this.timeAxis.getStart(),
  2989. this.timeAxis.getEnd())
  2990. } else {
  2991. b[c] = this.createHeaderRow(c, a[c])
  2992. }
  2993. }
  2994. return b
  2995. },
  2996. createHeaderRow : function(a, c) {
  2997. var b = [], d = this, f, e = c.align || "center";
  2998. this.timeAxis.forEachInterval(a, function(j, g, h) {
  2999. f = {
  3000. align : e,
  3001. start : j,
  3002. end : g,
  3003. headerCls : ""
  3004. };
  3005. if (c.renderer) {
  3006. f.header = c.renderer.call(c.scope || d, j, g, f, h)
  3007. } else {
  3008. f.header = d.defaultRenderer(j, g, c.dateFormat, f, h)
  3009. }
  3010. if (c.unit === Sch.util.Date.DAY
  3011. && (!c.increment || c.increment === 1)) {
  3012. f.headerCls += " sch-dayheadercell-" + j.getDay()
  3013. }
  3014. b.push(f)
  3015. });
  3016. return b
  3017. },
  3018. afterLayout : function() {
  3019. this.callParent(arguments);
  3020. this.refreshHeaderSizes()
  3021. },
  3022. refreshHeaderSizes : function() {
  3023. var a = this.columnConfig;
  3024. if (a.top) {
  3025. this.refreshHeaderRow("top")
  3026. }
  3027. if (a.middle) {
  3028. this.refreshHeaderRow("middle")
  3029. }
  3030. if (a.bottom) {
  3031. this.refreshHeaderRow("bottom")
  3032. }
  3033. },
  3034. refreshHeaderRow : function(a, b) {
  3035. var e = this.el;
  3036. var f = this.columnConfig[a];
  3037. var d = this;
  3038. var c;
  3039. var g = a === "bottom" || (a === "middle" && !this.columnConfig.bottom);
  3040. b = b || e.down(".sch-header-row-" + a, true);
  3041. Ext.fly(b).setWidth(d.getTotalWidth());
  3042. Ext.fly(b).select(" thead > tr > td").each(function(i, j, h) {
  3043. c = g ? d.columnWidth : d.getHeaderGroupCellWidth(f[h].start,
  3044. f[h].end);
  3045. i.setVisibilityMode(Ext.Element.DISPLAY);
  3046. if (c) {
  3047. if (Ext.isSafari && Ext.isMac) {
  3048. c -= 2
  3049. }
  3050. i.show();
  3051. i.setWidth(c - (Ext.chromeVersion === 19 ? (h ? 1 : 0) : 0))
  3052. } else {
  3053. i.hide()
  3054. }
  3055. });
  3056. if (a === "bottom") {
  3057. if (c < this.compactCellWidthThreshold) {
  3058. Ext.fly(b).addCls("sch-header-row-compact")
  3059. } else {
  3060. Ext.fly(b).removeCls("sch-header-row-compact")
  3061. }
  3062. }
  3063. },
  3064. getHeaderGroupCellWidth : function(c, a) {
  3065. var b = this.getSchedulingView();
  3066. return b.getXYFromDate(a)[0] - b.getXYFromDate(c)[0]
  3067. },
  3068. onElDblClick : function(d, f) {
  3069. var e = d.getTarget(".sch-column-header");
  3070. if (e) {
  3071. var a = Ext.fly(e).getAttribute("headerPosition"), b = Ext.fly(e)
  3072. .getAttribute("headerIndex"), c = this.columnConfig[a][b];
  3073. this.fireEvent("timeheaderdblclick", this, c.start, c.end, d)
  3074. }
  3075. },
  3076. getTimeColumnWidth : function() {
  3077. if (this.columnWidth === null) {
  3078. this.columnWidth = this.getWidth() / this.nbrTimeColumns
  3079. }
  3080. return this.columnWidth
  3081. },
  3082. setTimeColumnWidth : function(a) {
  3083. this.columnWidth = a;
  3084. if (this.rendered) {
  3085. Ext.suspendLayouts();
  3086. this.setWidth(a * this.nbrTimeColumns);
  3087. Ext.resumeLayouts();
  3088. this.refreshHeaderSizes();
  3089. this.ownerCt.updateLayout()
  3090. } else {
  3091. this.setWidth(a * this.nbrTimeColumns)
  3092. }
  3093. },
  3094. getTotalWidth : function() {
  3095. return this.columnWidth * this.nbrTimeColumns
  3096. },
  3097. highlightCell : function(c, a) {
  3098. var b = this;
  3099. if (a !== b.highlightedCell) {
  3100. b.clearHighlight();
  3101. b.highlightedCell = a;
  3102. Ext.fly(a).addCls(b.ownHoverCls)
  3103. }
  3104. },
  3105. clearHighlight : function() {
  3106. var b = this, a = b.highlightedCell;
  3107. if (a) {
  3108. Ext.fly(a).removeCls(b.ownHoverCls);
  3109. delete b.highlightedCell
  3110. }
  3111. }
  3112. });
  3113. Ext.define("Sch.mixin.Lockable", {
  3114. extend : "Ext.grid.Lockable",
  3115. requires : ["Sch.column.timeAxis.Horizontal",
  3116. "Sch.column.timeAxis.HorizontalSingle"],
  3117. findEditingPlugin : function() {
  3118. var b = this.plugins || [];
  3119. var c = this;
  3120. var a;
  3121. Ext.each(b, function(e, d) {
  3122. if (Ext.grid.plugin && Ext.grid.plugin.CellEditing
  3123. && e instanceof Ext.grid.plugin.CellEditing) {
  3124. a = e;
  3125. Ext.Array.remove(b, e);
  3126. return false
  3127. }
  3128. });
  3129. return a
  3130. },
  3131. processSchedulerPlugins : function() {
  3132. var e = [];
  3133. var d = [];
  3134. var g = [];
  3135. var a = this.plugins || [];
  3136. var c = this;
  3137. for (var b = a.length - 1; b >= 0; b--) {
  3138. var f = a[b];
  3139. if (f.lockableScope) {
  3140. switch (f.lockableScope) {
  3141. case "top" :
  3142. g.push(f);
  3143. break;
  3144. case "locked" :
  3145. e.push(f);
  3146. break;
  3147. case "normal" :
  3148. d.push(f);
  3149. break
  3150. }
  3151. Ext.Array.remove(a, f)
  3152. }
  3153. }
  3154. if (e.length > 0) {
  3155. c.lockedGridConfig.plugins = (c.lockedGridConfig.plugins || [])
  3156. .concat(e)
  3157. }
  3158. if (d.length > 0) {
  3159. c.normalGridConfig.plugins = (c.normalGridConfig.plugins || [])
  3160. .concat(d)
  3161. }
  3162. c.topPlugins = g
  3163. },
  3164. injectLockable : function() {
  3165. var d = this.findEditingPlugin();
  3166. var k = this;
  3167. var g = Ext.data.TreeStore && k.store instanceof Ext.data.TreeStore;
  3168. var m = k.store.buffered;
  3169. var c = k.getEventSelectionModel ? k.getEventSelectionModel() : k
  3170. .getSelectionModel();
  3171. k.lockedGridConfig = Ext.apply({}, k.lockedGridConfig || {});
  3172. k.normalGridConfig = Ext.apply({}, k.schedulerConfig
  3173. || k.normalGridConfig || {});
  3174. var a = k.lockedGridConfig, j = k.normalGridConfig;
  3175. Ext.applyIf(k.lockedGridConfig, {
  3176. xtype : k.lockedXType,
  3177. id : k.id + "_locked",
  3178. enableLocking : false,
  3179. lockable : false,
  3180. useArrows : true,
  3181. columnLines : k.columnLines,
  3182. rowLines : k.rowLines,
  3183. stateful : k.stateful,
  3184. delayScroll : function() {
  3185. if (this.rendered) {
  3186. return this.self.prototype.delayScroll.apply(this,
  3187. arguments)
  3188. }
  3189. },
  3190. split : true,
  3191. animCollapse : false,
  3192. collapseDirection : "left",
  3193. region : "west"
  3194. });
  3195. if (d) {
  3196. k.lockedGridConfig.plugins = (k.lockedGridConfig.plugins || [])
  3197. .concat(d)
  3198. }
  3199. k.processSchedulerPlugins();
  3200. Ext.applyIf(k.normalGridConfig, {
  3201. xtype : k.normalXType,
  3202. enableLocking : false,
  3203. lockable : false,
  3204. viewType : k.viewType,
  3205. layout : "fit",
  3206. sortableColumns : false,
  3207. enableColumnMove : false,
  3208. enableColumnResize : false,
  3209. enableColumnHide : false,
  3210. selModel : c,
  3211. eventSelModel : c,
  3212. _top : k,
  3213. orientation : k.orientation,
  3214. viewPreset : k.viewPreset,
  3215. timeAxis : k.timeAxis,
  3216. columnLines : k.columnLines,
  3217. rowLines : k.rowLines,
  3218. collapseDirection : "right",
  3219. animCollapse : false,
  3220. region : "center"
  3221. });
  3222. k.bothCfgCopy = k.bothCfgCopy
  3223. || (Ext.grid.Panel && Ext.grid.Panel.prototype.bothCfgCopy)
  3224. || ["invalidateScrollerOnRefresh", "hideHeaders",
  3225. "enableColumnHide", "enableColumnMove",
  3226. "enableColumnResize", "sortableColumns"];
  3227. if (k.orientation === "vertical") {
  3228. a.store = j.store = k.timeAxis.tickStore;
  3229. k.mon(k.resourceStore, {
  3230. clear : k.refreshResourceColumns,
  3231. datachanged : k.refreshResourceColumns,
  3232. update : k.refreshResourceColumns,
  3233. load : k.refreshResourceColumns,
  3234. scope : k
  3235. })
  3236. }
  3237. if (a.width) {
  3238. k.syncLockedWidth = Ext.emptyFn;
  3239. a.scroll = "horizontal";
  3240. a.scrollerOwner = true
  3241. }
  3242. if (k.resourceStore) {
  3243. j.resourceStore = k.resourceStore
  3244. }
  3245. if (k.eventStore) {
  3246. j.eventStore = k.eventStore
  3247. }
  3248. if (k.dependencyStore) {
  3249. j.dependencyStore = k.dependencyStore
  3250. }
  3251. var e = k.lockedViewConfig = k.lockedViewConfig || {};
  3252. var l = k.normalViewConfig = k.normalViewConfig || {};
  3253. if (g && m && Ext.getScrollbarSize().width === 0) {
  3254. k.lockedGridConfig.scroll = "horizontal"
  3255. }
  3256. if (m) {
  3257. e.preserveScrollOnRefresh = true
  3258. }
  3259. e.enableAnimations = k.normalViewConfig.enableAnimations = false;
  3260. if (g) {
  3261. if (Ext.versions.extjs.isLessThan("4.1.3")) {
  3262. k.normalViewConfig.providedStore = e.providedStore = k.store.nodeStore
  3263. } else {
  3264. k.normalViewConfig.store = e.store = k.store.nodeStore
  3265. }
  3266. k.overrideNodeStore(k.store.nodeStore)
  3267. }
  3268. var f = k.layout;
  3269. this.callParent(arguments);
  3270. if (k.topPlugins) {
  3271. k.plugins = k.topPlugins
  3272. }
  3273. if (a.width) {
  3274. k.lockedGrid.setWidth(a.width);
  3275. k.normalGrid.getView().addCls("sch-timeline-horizontal-scroll");
  3276. k.lockedGrid.getView().addCls("sch-locked-horizontal-scroll")
  3277. } else {
  3278. if (k.normalGrid.collapsed) {
  3279. k.normalGrid.collapsed = false;
  3280. k.normalGrid.view.on("boxready", function() {
  3281. k.normalGrid.collapse()
  3282. }, k, {
  3283. delay : 10
  3284. })
  3285. }
  3286. }
  3287. var n = k.lockedGrid.getView();
  3288. var b = k.normalGrid.getView();
  3289. var h;
  3290. if (m) {
  3291. h = k.normalGrid.verticalScroller;
  3292. n.on("render", this.onLockedViewRender, this);
  3293. this.fixPagingScroller(h);
  3294. if (Ext.getVersion("extjs").isLessThan("4.1.1")) {
  3295. if (Ext.getScrollbarSize().width > 0) {
  3296. n.on({
  3297. scroll : {
  3298. fn : k.onLockedViewScroll,
  3299. element : "el",
  3300. scope : k
  3301. }
  3302. })
  3303. }
  3304. }
  3305. }
  3306. if (Ext.getScrollbarSize().width === 0) {
  3307. n.addCls("sch-ganttpanel-force-locked-scroll")
  3308. }
  3309. if (g) {
  3310. this.setupLockableTree()
  3311. }
  3312. if (!b.deferInitialRefresh) {
  3313. var i = b.onRender;
  3314. b.onRender = function() {
  3315. this.doFirstRefresh = function() {
  3316. };
  3317. i.apply(this, arguments);
  3318. delete this.doFirstRefresh
  3319. }
  3320. }
  3321. if (m) {
  3322. b.el = {
  3323. un : function() {
  3324. }
  3325. };
  3326. h.bindView(b);
  3327. b.un("refresh", h.self.prototype.onViewRefresh, h);
  3328. delete b.el
  3329. }
  3330. k.view.clearListeners();
  3331. n.on({
  3332. refresh : k.updateSpacer,
  3333. scope : k
  3334. });
  3335. if (!Ext.grid.Lockable.prototype.updateSpacer) {
  3336. b.on({
  3337. refresh : k.updateSpacer,
  3338. scope : k
  3339. })
  3340. }
  3341. k.view = Ext.create("Sch.view.Locking", {
  3342. locked : k.lockedGrid,
  3343. normal : k.normalGrid,
  3344. panel : k
  3345. });
  3346. if (k.syncRowHeight) {
  3347. n.on("refresh", this.onLockedViewRefresh, this);
  3348. if (g) {
  3349. k.mon(k.store, {
  3350. beforeload : function() {
  3351. n.un({
  3352. itemadd : k.onViewItemAdd,
  3353. scope : k
  3354. });
  3355. b.un({
  3356. itemadd : k.onViewItemAdd,
  3357. scope : k
  3358. })
  3359. },
  3360. load : function() {
  3361. n.un({
  3362. itemadd : k.onViewItemAdd,
  3363. scope : k
  3364. });
  3365. b.un({
  3366. itemadd : k.onViewItemAdd,
  3367. scope : k
  3368. });
  3369. k.prepareFullRowHeightSync();
  3370. k.syncRowHeights()
  3371. }
  3372. });
  3373. k.normalGrid.on("afteritemexpand", k.afterNormalGridItemExpand,
  3374. k)
  3375. }
  3376. n.on({
  3377. itemadd : k.onViewItemAdd,
  3378. scope : k
  3379. });
  3380. b.on({
  3381. itemadd : k.onViewItemAdd,
  3382. itemupdate : k.onNormalViewItemUpdate,
  3383. groupexpand : k.onNormalViewGroupExpand,
  3384. scope : k
  3385. });
  3386. if (Ext.isIE9 && Ext.isStrict) {
  3387. k.onNormalViewItemUpdate = function(o, p, r) {
  3388. r = r.dom ? r.dom : r;
  3389. if (k.lockedGridDependsOnSchedule) {
  3390. var q = k.lockedGrid.getView();
  3391. q.suspendEvents();
  3392. q.onUpdate(k.lockedGrid.store, o);
  3393. q.resumeEvents()
  3394. }
  3395. var s = k.normalGrid.getView().getNode(p);
  3396. s.style.height = r.style.height;
  3397. k.normalHeights[p] = r.style.height;
  3398. k.syncRowHeights()
  3399. }
  3400. }
  3401. }
  3402. if (f !== "fit") {
  3403. k.layout = f
  3404. }
  3405. k.normalGrid.on({
  3406. collapse : k.onNormalGridCollapse,
  3407. expand : k.onNormalGridExpand,
  3408. scope : k
  3409. });
  3410. k.lockedGrid.on({
  3411. collapse : k.onLockedGridCollapse,
  3412. scope : k
  3413. });
  3414. if (this.lockedGrid.view.store !== this.normalGrid.view.store) {
  3415. Ext.Error
  3416. .raise("Sch.mixin.Lockable setup failed, not sharing store between the two views")
  3417. }
  3418. },
  3419. onLockedGridCollapse : function() {
  3420. if (this.normalGrid.collapsed) {
  3421. this.normalGrid.expand()
  3422. }
  3423. },
  3424. onNormalGridCollapse : function() {
  3425. var a = this;
  3426. if (!a.normalGrid.reExpander) {
  3427. a.normalGrid.reExpander = a.normalGrid.placeholder
  3428. }
  3429. if (!a.lockedGrid.rendered) {
  3430. a.lockedGrid.on("render", a.onNormalGridCollapse, a, {
  3431. delay : 1
  3432. })
  3433. } else {
  3434. a.lastLockedWidth = a.lockedGrid.getWidth();
  3435. a.lockedGrid.setWidth(a.getWidth() - 35);
  3436. if (a.lockedGrid.collapsed) {
  3437. a.lockedGrid.expand()
  3438. }
  3439. a.addCls("sch-normalgrid-collapsed")
  3440. }
  3441. },
  3442. onNormalGridExpand : function() {
  3443. this.removeCls("sch-normalgrid-collapsed");
  3444. this.lockedGrid.setWidth(this.lastLockedWidth)
  3445. },
  3446. fixPagingScroller : function(a) {
  3447. var b = a.onViewRefresh;
  3448. a.onViewRefresh = function() {
  3449. var j = this, l = j.store, i, k = j.view, o = k.el, p = o.dom, r, n, h, q = k.table.dom, m, g;
  3450. if (j.focusOnRefresh) {
  3451. o.focus();
  3452. j.focusOnRefresh = false
  3453. }
  3454. j.disabled = true;
  3455. var f = l.getCount() === l.getTotalCount();
  3456. j.stretcher.setHeight(i = j.getScrollHeight());
  3457. g = p.scrollTop;
  3458. j.isScrollRefresh = (g > 0);
  3459. if (j.scrollProportion !== undefined) {
  3460. j.setTablePosition("absolute");
  3461. j.setTableTop((j.scrollProportion && j.tableStart > 0
  3462. ? (i * j.scrollProportion)
  3463. - (q.offsetHeight * j.scrollProportion)
  3464. : 0)
  3465. + "px")
  3466. } else {
  3467. j.setTablePosition("absolute");
  3468. j.setTableTop((m = (j.tableStart || 0) * j.rowHeight) + "px");
  3469. if (j.scrollOffset) {
  3470. r = k.getNodes();
  3471. n = -o.getOffsetsTo(r[j.commonRecordIndex])[1];
  3472. h = n - j.scrollOffset;
  3473. j.position = (p.scrollTop += h)
  3474. } else {
  3475. if ((m > g) || ((m + q.offsetHeight) < g + p.clientHeight)) {
  3476. if (!(f && !m)) {
  3477. j.lastScrollDirection = -1;
  3478. j.position = p.scrollTop = m
  3479. }
  3480. }
  3481. }
  3482. }
  3483. j.disabled = false
  3484. };
  3485. a.setViewTableStyle = function(f, h, g) {
  3486. if (f.table.dom) {
  3487. f.table.dom.style[h] = g
  3488. }
  3489. f = f.lockingPartner;
  3490. if (f) {
  3491. if (f.table.dom) {
  3492. f.table.dom.style[h] = g
  3493. }
  3494. }
  3495. };
  3496. var d = a.view.lockingPartner;
  3497. if (d) {
  3498. var e = a.onLockRefresh;
  3499. var c = function(f) {
  3500. if (f.table.dom) {
  3501. e.apply(this, arguments)
  3502. }
  3503. };
  3504. d.un("refresh", e, a);
  3505. d.on("refresh", c, a);
  3506. a.onLockRefresh = c
  3507. }
  3508. a.view.un("render", a.onViewRender, a);
  3509. a.onViewRender = function() {
  3510. var g = this, f = g.view.el;
  3511. f.setStyle("position", "relative");
  3512. g.stretcher = f.createChild({
  3513. style : {
  3514. position : "absolute",
  3515. width : "1px",
  3516. height : 0,
  3517. top : 0,
  3518. left : 0
  3519. }
  3520. }, f.dom.firstChild)
  3521. };
  3522. a.view.on("render", a.onViewRender, a);
  3523. if (Ext.getVersion("extjs").isLessThan("4.1.3")) {
  3524. a.scrollTo = function(m, g, p, r) {
  3525. var j = this, l = j.view, q = l.el.dom, n = j.store, k = n
  3526. .getTotalCount(), i, f, h, o;
  3527. m = Math.min(Math.max(m, 0), k - 1);
  3528. i = Math
  3529. .max(
  3530. Math
  3531. .min(
  3532. m
  3533. - ((j.leadingBufferZone + j.trailingBufferZone) / 2),
  3534. k - j.viewSize + 1), 0);
  3535. o = i * j.rowHeight;
  3536. f = i + j.viewSize - 1;
  3537. j.lastScrollDirection = undefined;
  3538. j.disabled = true;
  3539. n.guaranteeRange(i, f, function() {
  3540. h = n.pageMap.getRange(m, m)[0];
  3541. l.table.dom.style.top = o + "px";
  3542. q.scrollTop = o = Math.min(Math.max(0,
  3543. o
  3544. - l.table.getOffsetsTo(l
  3545. .getNode(h))[1]),
  3546. q.scrollHeight - q.clientHeight);
  3547. if (Ext.isIE) {
  3548. q.scrollTop = o
  3549. }
  3550. j.disabled = false;
  3551. if (g) {
  3552. j.grid.selModel.select(h)
  3553. }
  3554. if (p) {
  3555. p.call(r || j, m, h)
  3556. }
  3557. })
  3558. }
  3559. }
  3560. },
  3561. onLockedViewScroll : function() {
  3562. if (this.store.buffered) {
  3563. var a = this.normalGrid.getView().el;
  3564. if (!a || !a.child("table", true)) {
  3565. return
  3566. }
  3567. }
  3568. return this.callParent(arguments)
  3569. },
  3570. onNormalViewScroll : function() {
  3571. if (this.store.buffered) {
  3572. var a = this.lockedGrid.getView().el;
  3573. if (!a || !a.child("table", true)) {
  3574. return
  3575. }
  3576. }
  3577. return this.callParent(arguments)
  3578. },
  3579. setupLockableTree : function() {
  3580. var h = this;
  3581. var i = h.store.buffered;
  3582. var c = h.getView();
  3583. var l = h.lockedGrid.getView();
  3584. var d = h.normalGrid.getView();
  3585. var j = d.store;
  3586. var b = h.store;
  3587. var e = Sch.mixin.FilterableTreeView.prototype;
  3588. l.initTreeFiltering = e.initTreeFiltering;
  3589. l.onFilterChangeStart = e.onFilterChangeStart;
  3590. l.onFilterChangeEnd = e.onFilterChangeEnd;
  3591. l.onFilterCleared = e.onFilterCleared;
  3592. l.onFilterSet = e.onFilterSet;
  3593. l.initTreeFiltering();
  3594. if (i) {
  3595. b.on("nodestore-datachange-end", function() {
  3596. if (d.rendered) {
  3597. h.onNormalViewScroll()
  3598. }
  3599. })
  3600. } else {
  3601. this.mon(b, {
  3602. "root-fill-start" : function() {
  3603. j.suspendEvents()
  3604. },
  3605. "root-fill-end" : function() {
  3606. j.resumeEvents();
  3607. c.refresh()
  3608. }
  3609. })
  3610. }
  3611. this.mon(b, "filter", function(n, m) {
  3612. j.filter.apply(j, m);
  3613. c.refresh()
  3614. });
  3615. this.mon(b, "clearfilter", function(m) {
  3616. j.clearFilter();
  3617. c.refresh()
  3618. });
  3619. var g = h.normalGrid.verticalScroller;
  3620. if (i && g) {
  3621. var a = g.onGuaranteedRange;
  3622. g.onGuaranteedRange = function() {
  3623. a.apply(this, arguments);
  3624. Ext.suspendLayouts();
  3625. c.refresh();
  3626. Ext.resumeLayouts()
  3627. }
  3628. }
  3629. var k = l.onAdd;
  3630. var f = l.onRemove;
  3631. l.onAdd = function() {
  3632. Ext.suspendLayouts();
  3633. k.apply(this, arguments);
  3634. Ext.resumeLayouts()
  3635. };
  3636. l.onRemove = function() {
  3637. Ext.suspendLayouts();
  3638. f.apply(this, arguments);
  3639. Ext.resumeLayouts()
  3640. }
  3641. },
  3642. onNormalViewItemUpdate : function(a, b, d) {
  3643. d = d.dom ? d.dom : d;
  3644. if (this.lockedGridDependsOnSchedule) {
  3645. var c = this.lockedGrid.getView();
  3646. c.suspendEvents();
  3647. c.onUpdate(this.lockedGrid.store, a);
  3648. c.resumeEvents()
  3649. }
  3650. var f = this.normalGrid.getView().getNode(b);
  3651. var e = f.style.height !== d.style.height;
  3652. f.style.height = d.style.height;
  3653. this.normalHeights[b] = d.style.height;
  3654. this.syncRowHeights(e)
  3655. },
  3656. afterNormalGridItemExpand : function(a) {
  3657. var c = this;
  3658. var b = c.getSchedulingView();
  3659. a.cascadeBy(function(f) {
  3660. if (f !== a) {
  3661. var e = b.getNode(f);
  3662. if (e) {
  3663. var d = b.indexOf(e);
  3664. c.normalHeights[d] = e.style.height
  3665. }
  3666. }
  3667. });
  3668. c.syncRowHeights(true)
  3669. },
  3670. onViewItemAdd : function(c, d, b) {
  3671. var e = this.normalGrid.getView();
  3672. var f = this.lockedGrid.getView();
  3673. if (e.getNodes().length !== f.getNodes().length) {
  3674. return
  3675. }
  3676. var a = this.normalHeights;
  3677. Ext.each(c, function(h, g) {
  3678. var i = e.getNode(h);
  3679. if (i) {
  3680. a[i.viewIndex] = i.style.height
  3681. }
  3682. });
  3683. this.syncRowHeights()
  3684. },
  3685. processColumns : function(b) {
  3686. var a = this.callParent(arguments);
  3687. var c = [];
  3688. Ext.each(b, function(d) {
  3689. if (d.position == "right") {
  3690. d.processed = true;
  3691. if (!Ext.isNumber(d.width)) {
  3692. Ext.Error
  3693. .raise('"Right" columns must have a fixed width')
  3694. }
  3695. c.push(d);
  3696. Ext.Array.remove(a.locked.items, d);
  3697. a.lockedWidth -= d.width
  3698. }
  3699. });
  3700. if (this.orientation === "horizontal") {
  3701. a.normal.items = [{
  3702. xtype : this.lightWeight
  3703. ? "singletimeaxiscolumn"
  3704. : "timeaxiscolumn",
  3705. timeAxis : this.timeAxis,
  3706. timeCellRenderer : this.timeCellRenderer,
  3707. timeCellRendererScope : this.timeCellRendererScope,
  3708. trackHeaderOver : this.trackHeaderOver
  3709. }].concat(c)
  3710. } else {
  3711. a.locked.items = [Ext.apply({
  3712. xtype : "verticaltimeaxis",
  3713. width : 100,
  3714. timeAxis : this.timeAxis
  3715. }, this.timeAxisColumnCfg || {})];
  3716. a.lockedWidth = a.locked.items[0].width
  3717. }
  3718. return a
  3719. },
  3720. prepareFullRowHeightSync : function() {
  3721. var g = this, h = g.normalGrid.getView(), j = g.lockedGrid.getView();
  3722. if (!h.rendered || !j.rendered) {
  3723. return
  3724. }
  3725. var a = h.el, d = j.el, f = a.query(h.getItemSelector()), b = d.query(j
  3726. .getItemSelector()), e = f.length, c = 0;
  3727. g.lockedHeights = [];
  3728. g.normalHeights = [];
  3729. if (b.length !== e) {
  3730. return
  3731. }
  3732. for (; c < e; c++) {
  3733. g.normalHeights[c] = f[c].style.height
  3734. }
  3735. },
  3736. onLockedViewRefresh : function() {
  3737. this.prepareFullRowHeightSync();
  3738. this.syncRowHeights()
  3739. },
  3740. onNormalViewRefresh : function() {
  3741. var a = this.lockedGrid.getView();
  3742. if (this.lockedGridDependsOnSchedule) {
  3743. a.un("refresh", this.onLockedViewRefresh, this);
  3744. this.lockedGrid.getView().refresh();
  3745. a.on("refresh", this.onLockedViewRefresh, this)
  3746. }
  3747. this.prepareFullRowHeightSync();
  3748. this.syncRowHeights()
  3749. },
  3750. syncRowHeights : function(b) {
  3751. if (!this.lockedGrid.getView().rendered
  3752. || !this.normalGrid.getView().rendered) {
  3753. return
  3754. }
  3755. var j = this, c = j.lockedHeights, k = j.normalHeights, a = [], h = c.length
  3756. || k.length, f = 0, l, d, e, g;
  3757. if (c.length || k.length) {
  3758. l = j.lockedGrid.getView();
  3759. d = j.normalGrid.getView();
  3760. e = l.el.query(l.getItemSelector());
  3761. g = d.el.query(d.getItemSelector());
  3762. if (g.length !== e.length) {
  3763. return
  3764. }
  3765. for (; f < h; f++) {
  3766. if (e[f] && k[f]) {
  3767. e[f].style.height = k[f]
  3768. }
  3769. }
  3770. j.lockedHeights = [];
  3771. j.normalHeights = []
  3772. }
  3773. if (b !== false) {
  3774. j.updateSpacer()
  3775. }
  3776. },
  3777. getMenuItems : function() {
  3778. if (Ext.versions.extjs.isGreaterThanOrEqual("4.1.2")) {
  3779. return this.callParent(arguments)
  3780. }
  3781. return function() {
  3782. return Ext.grid.header.Container.prototype.getMenuItems.apply(this,
  3783. arguments)
  3784. }
  3785. },
  3786. applyColumnsState : Ext.emptyFn,
  3787. updateSpacer : function() {
  3788. var g = this.lockedGrid.getView();
  3789. var e = this.normalGrid.getView();
  3790. if (g.rendered && e.rendered && g.el.child("table")
  3791. && !this.getSchedulingView().__lightRefresh) {
  3792. var f = this, c = g.el, d = e.el.dom, b = c.dom.id + "-spacer", h = (d.offsetHeight - d.clientHeight)
  3793. + "px";
  3794. f.spacerEl = Ext.getDom(b);
  3795. if (Ext.isIE6 || Ext.isIE7 || (Ext.isIEQuirks && Ext.isIE8)
  3796. && f.spacerEl) {
  3797. Ext.removeNode(f.spacerEl);
  3798. f.spacerEl = null
  3799. }
  3800. if (f.spacerEl) {
  3801. f.spacerEl.style.height = h
  3802. } else {
  3803. var a;
  3804. if (this.store.buffered) {
  3805. a = f.normalGrid.verticalScroller.stretcher.item(0).dom.parentNode === c.dom
  3806. ? f.normalGrid.verticalScroller.stretcher.item(0)
  3807. : f.normalGrid.verticalScroller.stretcher.item(1)
  3808. } else {
  3809. a = c
  3810. }
  3811. Ext.core.DomHelper.append(a, {
  3812. id : b,
  3813. cls : this.store.buffered
  3814. ? "sch-locked-buffered-spacer"
  3815. : "",
  3816. style : "height: " + h
  3817. })
  3818. }
  3819. }
  3820. },
  3821. onLockedViewRender : function() {
  3822. var e = this.normalGrid;
  3823. if (!this.lockedStretcher) {
  3824. var c = this.lockedGrid.getView().el;
  3825. var a = this.lockedStretcher = c.createChild({
  3826. cls : "x-stretcher",
  3827. style : {
  3828. position : "absolute",
  3829. width : "1px",
  3830. height : 0,
  3831. top : 0,
  3832. left : 0
  3833. }
  3834. }, c.dom.firstChild)
  3835. }
  3836. if (!e.rendered) {
  3837. e.getView().on("render", this.onLockedViewRender, this);
  3838. return
  3839. }
  3840. var d = this;
  3841. setTimeout(function() {
  3842. var f = e.getView().el;
  3843. if (f && f.dom) {
  3844. e.getView().el.un("scroll", d.onNormalViewScroll, d);
  3845. e.getView().el.on("scroll", d.onNormalViewScroll, d)
  3846. }
  3847. }, 0);
  3848. var b = e.verticalScroller;
  3849. b.stretcher.addCls("x-stretcher");
  3850. b.stretcher = new Ext.dom.CompositeElement([this.lockedStretcher,
  3851. b.stretcher])
  3852. },
  3853. onNormalViewGroupExpand : function() {
  3854. this.prepareFullRowHeightSync();
  3855. this.syncRowHeights()
  3856. },
  3857. overrideNodeStore : function(c) {
  3858. var a = c.onNodeCollapse;
  3859. var b = c.onNodeExpand;
  3860. c.onNodeCollapse = function() {
  3861. Ext.suspendLayouts();
  3862. a.apply(this, arguments);
  3863. Ext.resumeLayouts()
  3864. };
  3865. c.onNodeExpand = function() {
  3866. Ext.suspendLayouts();
  3867. b.apply(this, arguments);
  3868. Ext.resumeLayouts()
  3869. }
  3870. }
  3871. });
  3872. Ext.define("Sch.plugin.TreeCellEditing", {
  3873. extend : "Ext.grid.plugin.CellEditing",
  3874. init : function(a) {
  3875. this._grid = a;
  3876. this.on("beforeedit", this.checkReadOnly, this);
  3877. this.callParent(arguments)
  3878. },
  3879. checkReadOnly : function() {
  3880. var a = this._grid;
  3881. if (!(a instanceof Sch.panel.TimelineTreePanel)) {
  3882. a = a.up("tablepanel")
  3883. }
  3884. return !a.isReadOnly()
  3885. },
  3886. startEditByClick : function(c, a, h, b, g, d, f) {
  3887. if (f.getTarget(c.expanderSelector)) {
  3888. return
  3889. }
  3890. this.callParent(arguments)
  3891. },
  3892. startEdit : function(a, f) {
  3893. if (!a || !f) {
  3894. return
  3895. }
  3896. var d = this, b = d.getEditor(a, f), e = a.get(f.dataIndex), c = d
  3897. .getEditingContext(a, f);
  3898. a = c.record;
  3899. f = c.column;
  3900. d.completeEdit();
  3901. if (f && !f.getEditor(a)) {
  3902. return false
  3903. }
  3904. if (b) {
  3905. c.originalValue = c.value = e;
  3906. if (d.beforeEdit(c) === false
  3907. || d.fireEvent("beforeedit", c) === false || c.cancel) {
  3908. return false
  3909. }
  3910. d.context = c;
  3911. d.setActiveEditor(b);
  3912. d.setActiveRecord(a);
  3913. d.setActiveColumn(f);
  3914. d.grid.view.focusCell({
  3915. column : c.colIdx,
  3916. row : c.rowIdx
  3917. });
  3918. d.editTask.delay(15, d.showEditor, d, [b, c, c.value])
  3919. } else {
  3920. d.grid.getView().getEl(f).focus((Ext.isWebKit || Ext.isIE)
  3921. ? 10
  3922. : false)
  3923. }
  3924. },
  3925. showEditor : function(b, c, g) {
  3926. var e = this, a = c.record, f = c.column, h = e.grid
  3927. .getSelectionModel(), d = h.getCurrentPosition
  3928. && h.getCurrentPosition();
  3929. e.context = c;
  3930. e.setActiveEditor(b);
  3931. e.setActiveRecord(a);
  3932. e.setActiveColumn(f);
  3933. if (h.selectByPosition
  3934. && (!d || d.column !== c.colIdx || d.row !== c.rowIdx)) {
  3935. h.selectByPosition({
  3936. row : c.rowIdx,
  3937. column : c.colIdx
  3938. })
  3939. }
  3940. b.startEdit(e.getCell(a, f), g, c);
  3941. e.editing = true;
  3942. e.scroll = e.view.el.getScroll()
  3943. },
  3944. getEditingContext : function(e, c) {
  3945. var f = this, a = f.grid, i = a.store, b, d, g = a.getView(), h;
  3946. if (Ext.isNumber(e)) {
  3947. b = e;
  3948. e = i.getAt(b)
  3949. } else {
  3950. if (i instanceof Ext.data.Store) {
  3951. b = i.indexOf(e)
  3952. } else {
  3953. b = g.indexOf(g.getNode(e))
  3954. }
  3955. }
  3956. if (Ext.isNumber(c)) {
  3957. d = c;
  3958. c = a.headerCt.getHeaderAtIndex(d)
  3959. } else {
  3960. d = c.getIndex()
  3961. }
  3962. h = e.get(c.dataIndex);
  3963. return {
  3964. grid : a,
  3965. record : e,
  3966. field : c.dataIndex,
  3967. value : h,
  3968. row : g.getNode(b),
  3969. column : c,
  3970. rowIdx : b,
  3971. colIdx : d
  3972. }
  3973. },
  3974. startEditByPosition : function(a) {
  3975. var f = this, d = f.grid, h = d.getSelectionModel(), b = f.view, e = this.view
  3976. .getNode(a.row), g = d.headerCt.getHeaderAtIndex(a.column), c = b
  3977. .getRecord(e);
  3978. if (h.selectByPosition) {
  3979. h.selectByPosition(a)
  3980. }
  3981. f.startEdit(c, g)
  3982. },
  3983. onEditComplete : function(c, g, b) {
  3984. var f = this, d = f.grid, e = f.getActiveColumn(), h = d
  3985. .getSelectionModel(), a;
  3986. if (e) {
  3987. a = f.context.record;
  3988. f.setActiveEditor(null);
  3989. f.setActiveColumn(null);
  3990. f.setActiveRecord(null);
  3991. if (!f.validateEdit()) {
  3992. return
  3993. }
  3994. if (!f.context.doNotUpdateRecord && !a.isEqual(g, b)) {
  3995. a.set(e.dataIndex, g)
  3996. }
  3997. if (h.setCurrentPosition) {
  3998. h.setCurrentPosition(h.getCurrentPosition())
  3999. }
  4000. d.getView().getEl(e).focus();
  4001. f.context.value = g;
  4002. f.fireEvent("edit", f, f.context)
  4003. }
  4004. },
  4005. onSpecialKey : function(a, f, d) {
  4006. if (!Ext.versions.extjs.equals("4.1.2.381")) {
  4007. return this.callParent(arguments)
  4008. }
  4009. var c = this, b = this.grid, g;
  4010. if (d.getKey() === d.TAB) {
  4011. d.stopEvent();
  4012. if (a) {
  4013. a.onEditorTab(d)
  4014. }
  4015. g = b.getSelectionModel();
  4016. if (g.onEditorTab) {
  4017. return g.onEditorTab(b === c.grid ? c : c.lockingPartner, d)
  4018. }
  4019. }
  4020. }
  4021. });
  4022. Ext.define("Sch.feature.ColumnLines", {
  4023. extend : "Sch.plugin.Lines",
  4024. cls : "sch-column-line",
  4025. showTip : false,
  4026. requires : ["Ext.data.Store"],
  4027. init : function(b) {
  4028. this.timeAxis = b.getTimeAxis();
  4029. this.store = Ext.create("Ext.data.JsonStore", {
  4030. model : Ext.define("Sch.model.TimeLine", {
  4031. extend : "Ext.data.Model",
  4032. fields : ["start", {
  4033. name : "Date",
  4034. convert : function(d, c) {
  4035. return c.data.start
  4036. }
  4037. }]
  4038. }),
  4039. data : b.getOrientation() === "horizontal" ? this
  4040. .getData() : []
  4041. });
  4042. this.callParent(arguments);
  4043. var a = this.schedulerView;
  4044. a.timeAxis.on("reconfigure", this.populate, this)
  4045. },
  4046. populate : function() {
  4047. var a = this.schedulerView;
  4048. var b = a.getOrientation() === "horizontal"
  4049. && a.store.getCount() > 0;
  4050. this.store.removeAll(b);
  4051. if (b) {
  4052. this.store.add(this.getData())
  4053. }
  4054. },
  4055. getElementData : function() {
  4056. var a = this.schedulerView;
  4057. if (a.getOrientation() === "horizontal"
  4058. && a.store.getCount() > 0) {
  4059. return this.callParent(arguments)
  4060. }
  4061. return []
  4062. },
  4063. getData : function() {
  4064. var a = [];
  4065. this.timeAxis.forEachMainInterval(function(d, b, c) {
  4066. if (c > 0) {
  4067. a.push({
  4068. start : d
  4069. })
  4070. }
  4071. });
  4072. a.push({
  4073. start : this.timeAxis.getEnd()
  4074. });
  4075. return a
  4076. }
  4077. });
  4078. Ext.define("Sch.plugin.CurrentTimeLine", {
  4079. extend : "Sch.plugin.Lines",
  4080. tooltipText : "Current time",
  4081. updateInterval : 60000,
  4082. autoUpdate : true,
  4083. expandToFitView : true,
  4084. init : function(c) {
  4085. var b = Ext.create("Ext.data.JsonStore", {
  4086. fields : ["Date", "Cls", "Text"],
  4087. data : [{
  4088. Date : new Date(),
  4089. Cls : "sch-todayLine",
  4090. Text : this.tooltipText
  4091. }]
  4092. });
  4093. var a = b.first();
  4094. if (this.autoUpdate) {
  4095. this.runner = Ext.create("Ext.util.TaskRunner");
  4096. this.runner.start({
  4097. run : function() {
  4098. a.set("Date", new Date())
  4099. },
  4100. interval : this.updateInterval
  4101. })
  4102. }
  4103. c.on("destroy", this.onHostDestroy, this);
  4104. this.store = b;
  4105. this.callParent(arguments)
  4106. },
  4107. onHostDestroy : function() {
  4108. if (this.runner) {
  4109. this.runner.stopAll()
  4110. }
  4111. if (this.store.autoDestroy) {
  4112. this.store.destroy()
  4113. }
  4114. }
  4115. });
  4116. Ext.define("Sch.mixin.TimelineView", {
  4117. requires : ["Sch.column.Time", "Sch.data.TimeAxis"],
  4118. orientation : "horizontal",
  4119. overScheduledEventClass : "sch-event-hover",
  4120. selectedEventCls : "sch-event-selected",
  4121. altColCls : "sch-col-alt",
  4122. timeCellCls : "sch-timetd",
  4123. timeCellSelector : ".sch-timetd",
  4124. ScheduleEventMap : {
  4125. click : "Click",
  4126. mousedown : "MouseDown",
  4127. mouseup : "MouseUp",
  4128. dblclick : "DblClick",
  4129. contextmenu : "ContextMenu",
  4130. keydown : "KeyDown",
  4131. keyup : "KeyUp"
  4132. },
  4133. suppressFitCheck : 0,
  4134. forceFit : false,
  4135. inheritables : function() {
  4136. return {
  4137. cellBorderWidth : 1,
  4138. initComponent : function() {
  4139. this.setOrientation(this.panel._top.orientation
  4140. || this.orientation);
  4141. this.addEvents("beforetooltipshow", "scheduleclick",
  4142. "scheduledblclick", "schedulecontextmenu",
  4143. "columnwidthchange");
  4144. this.enableBubble("columnwidthchange");
  4145. var a = {}, c = Sch.util.Date;
  4146. a[c.DAY] = a[c.WEEK] = a[c.MONTH] = a[c.QUARTER] = a[c.YEAR] = null;
  4147. Ext.applyIf(this, {
  4148. eventPrefix : this.id + "-",
  4149. largeUnits : a
  4150. });
  4151. this.callParent(arguments);
  4152. if (this.orientation === "horizontal") {
  4153. this.getTimeAxisColumn().on("timeaxiscolumnreconfigured",
  4154. this.checkHorizontalFit, this)
  4155. }
  4156. var b = this.panel._top;
  4157. Ext.apply(this, {
  4158. eventRendererScope : b.eventRendererScope,
  4159. eventRenderer : b.eventRenderer,
  4160. eventBorderWidth : b.eventBorderWidth,
  4161. timeAxis : b.timeAxis,
  4162. dndValidatorFn : b.dndValidatorFn || Ext.emptyFn,
  4163. resizeValidatorFn : b.resizeValidatorFn
  4164. || Ext.emptyFn,
  4165. createValidatorFn : b.createValidatorFn
  4166. || Ext.emptyFn,
  4167. tooltipTpl : b.tooltipTpl,
  4168. validatorFnScope : b.validatorFnScope || this,
  4169. snapToIncrement : b.snapToIncrement,
  4170. timeCellRenderer : b.timeCellRenderer,
  4171. timeCellRendererScope : b.timeCellRendererScope,
  4172. readOnly : b.readOnly,
  4173. eventResizeHandles : b.eventResizeHandles,
  4174. enableEventDragDrop : b.enableEventDragDrop,
  4175. enableDragCreation : b.enableDragCreation,
  4176. dragConfig : b.dragConfig,
  4177. dropConfig : b.dropConfig,
  4178. resizeConfig : b.resizeConfig,
  4179. createConfig : b.createConfig,
  4180. tipCfg : b.tipCfg,
  4181. orientation : b.orientation,
  4182. getDateConstraints : b.getDateConstraints
  4183. || Ext.emptyFn
  4184. });
  4185. if (this.emptyText) {
  4186. this.emptyText = '<span class="sch-empty-text">'
  4187. + this.emptyText + "</span>"
  4188. }
  4189. },
  4190. onDestroy : function() {
  4191. if (this.tip) {
  4192. this.tip.destroy()
  4193. }
  4194. this.callParent(arguments)
  4195. },
  4196. afterComponentLayout : function() {
  4197. this.callParent(arguments);
  4198. var b = this.getWidth();
  4199. var a = this.getHeight();
  4200. if (b === this.__prevWidth && a === this.__prevHeight) {
  4201. return
  4202. }
  4203. this.__prevWidth = b;
  4204. this.__prevHeight = a;
  4205. if (!this.lockable && !this.suppressFitCheck) {
  4206. this.checkHorizontalFit()
  4207. }
  4208. },
  4209. beforeRender : function() {
  4210. this.callParent(arguments);
  4211. this.addCls("sch-timelineview");
  4212. if (this.readOnly) {
  4213. this.addCls(this._cmpCls + "-readonly")
  4214. }
  4215. },
  4216. afterRender : function() {
  4217. this.callParent(arguments);
  4218. if (this.overScheduledEventClass) {
  4219. this.mon(this.el, {
  4220. mouseover : this.onMouseOver,
  4221. mouseout : this.onMouseOut,
  4222. delegate : this.eventSelector,
  4223. scope : this
  4224. })
  4225. }
  4226. if (this.tooltipTpl) {
  4227. this.el.on("mousemove", this.setupTooltip, this, {
  4228. single : true
  4229. })
  4230. }
  4231. this.setupTimeCellEvents()
  4232. },
  4233. processUIEvent : function(f) {
  4234. var c = this, a = f.getTarget(this.eventSelector), d = c.ScheduleEventMap, b = f.type, g = false;
  4235. if (a && b in d) {
  4236. this.fireEvent(this.scheduledEventName + b, this, this
  4237. .resolveEventRecord(a), f);
  4238. g = !(this.panel.getSelectionModel() instanceof Ext.selection.RowModel)
  4239. }
  4240. if (!g) {
  4241. this.callParent(arguments)
  4242. }
  4243. },
  4244. refresh : function() {
  4245. this.fixedNodes = 0;
  4246. this.callParent(arguments)
  4247. },
  4248. clearViewEl : function() {
  4249. var c = this, b = c.getTargetEl();
  4250. b.down("table").remove();
  4251. if (this.emptyText) {
  4252. var a = b.down(".sch-empty-text");
  4253. if (a) {
  4254. a.remove()
  4255. }
  4256. }
  4257. },
  4258. onMouseOver : function(b, a) {
  4259. if (a !== this.lastItem) {
  4260. this.lastItem = a;
  4261. Ext.fly(a).addCls(this.overScheduledEventClass);
  4262. this.fireEvent("eventmouseenter", this, this
  4263. .resolveEventRecord(a), b)
  4264. }
  4265. },
  4266. onMouseOut : function(b, a) {
  4267. if (this.lastItem) {
  4268. if (!b.within(this.lastItem, true, true)) {
  4269. Ext.fly(this.lastItem)
  4270. .removeCls(this.overScheduledEventClass);
  4271. this.fireEvent("eventmouseleave", this, this
  4272. .resolveEventRecord(this.lastItem), b);
  4273. delete this.lastItem
  4274. }
  4275. }
  4276. },
  4277. highlightItem : function(b) {
  4278. if (b) {
  4279. var a = this;
  4280. a.clearHighlight();
  4281. a.highlightedItem = b;
  4282. Ext.fly(b).addCls(a.overItemCls)
  4283. }
  4284. },
  4285. shouldUpdateCell : function() {
  4286. return true
  4287. }
  4288. }
  4289. },
  4290. hasRightColumns : function() {
  4291. return this.headerCt.items.getCount() > 1
  4292. },
  4293. checkHorizontalFit : function() {
  4294. if (this.orientation === "horizontal") {
  4295. var a = this.getActualTimeColumnWidth();
  4296. var c = this.getFittingColumnWidth();
  4297. if (this.forceFit) {
  4298. if (c != a) {
  4299. this.fitColumns()
  4300. }
  4301. } else {
  4302. if (this.snapToIncrement) {
  4303. var b = this.calculateTimeColumnWidth(a);
  4304. if (b > 0 && b !== a) {
  4305. this.setColumnWidth(b)
  4306. }
  4307. } else {
  4308. if (a < c) {
  4309. this.fitColumns()
  4310. }
  4311. }
  4312. }
  4313. }
  4314. },
  4315. getTimeAxisColumn : function() {
  4316. return this.headerCt.items.get(0)
  4317. },
  4318. getFirstTimeColumn : function() {
  4319. return this.headerCt.getGridColumns()[0]
  4320. },
  4321. getFormattedDate : function(a) {
  4322. return Ext.Date.format(a, this.getDisplayDateFormat())
  4323. },
  4324. getFormattedEndDate : function(d, a) {
  4325. var b = this.timeAxis, c = b.getResolution().unit;
  4326. if (c in this.largeUnits
  4327. && d.getHours() === 0
  4328. && d.getMinutes() === 0
  4329. && !(d.getYear() === a.getYear()
  4330. && d.getMonth() === a.getMonth() && d.getDate() === a
  4331. .getDate())) {
  4332. d = Sch.util.Date.add(d, Sch.util.Date.DAY, -1)
  4333. }
  4334. return Ext.Date.format(d, this.getDisplayDateFormat())
  4335. },
  4336. getDisplayDateFormat : function() {
  4337. return this.displayDateFormat
  4338. },
  4339. setDisplayDateFormat : function(a) {
  4340. this.displayDateFormat = a
  4341. },
  4342. getSingleUnitInPixels : function(a) {
  4343. return Sch.util.Date.getUnitToBaseUnitRatio(this.timeAxis.getUnit(), a)
  4344. * this.getSingleTickInPixels() / this.timeAxis.getIncrement()
  4345. },
  4346. getSingleTickInPixels : function() {
  4347. throw "Must be implemented by horizontal/vertical"
  4348. },
  4349. scrollEventIntoView : function(f, c, a, j, k) {
  4350. k = k || this;
  4351. var h = this;
  4352. var d = this.panel._top.store;
  4353. var i = function(l) {
  4354. l.scrollIntoView(h.el, true, a);
  4355. if (c) {
  4356. if (typeof c === "boolean") {
  4357. l.highlight()
  4358. } else {
  4359. l.highlight(null, c)
  4360. }
  4361. }
  4362. j && j.call(k)
  4363. };
  4364. var e = Ext.data && Ext.data.TreeStore
  4365. && d instanceof Ext.data.TreeStore && !f.isVisible();
  4366. if (e) {
  4367. f.bubble(function(l) {
  4368. l.expand()
  4369. })
  4370. }
  4371. var b = this.getOuterElementFromEventRecord(f);
  4372. if (b) {
  4373. i(b)
  4374. } else {
  4375. var g = this.panel.verticalScroller;
  4376. if (d.buffered && g) {
  4377. Ext.Function.defer(function() {
  4378. g.scrollTo(d.getIndexInTotalDataset(f), false,
  4379. function() {
  4380. var l = h
  4381. .getOuterElementFromEventRecord(f);
  4382. if (l) {
  4383. i(l)
  4384. }
  4385. })
  4386. }, e ? 10 : 0)
  4387. }
  4388. }
  4389. },
  4390. calculateTimeColumnWidth : function(e) {
  4391. if (!this.panel.rendered) {
  4392. return e
  4393. }
  4394. var h = this.forceFit;
  4395. var b = 0, d = this.timeAxis.getUnit(), k = this.timeAxis.getCount(), g = Number.MAX_VALUE;
  4396. if (this.snapToIncrement) {
  4397. var i = this.timeAxis.getResolution(), j = i.unit, c = i.increment;
  4398. g = Sch.util.Date.getUnitToBaseUnitRatio(d, j) * c
  4399. }
  4400. var f = Sch.util.Date.getMeasuringUnit(d);
  4401. g = Math.min(g, Sch.util.Date.getUnitToBaseUnitRatio(d, f));
  4402. var a = Math.floor(this.getAvailableWidthForSchedule() / k);
  4403. b = (h || e < a) ? a : e;
  4404. if (g > 0 && (!h || g < 1)) {
  4405. b = Math.round(Math.max(1, Math[h ? "floor" : "round"](g * b)) / g)
  4406. }
  4407. return b
  4408. },
  4409. getFittingColumnWidth : function() {
  4410. var a = Math.floor(this.getAvailableWidthForSchedule()
  4411. / this.timeAxis.getCount());
  4412. return this.calculateTimeColumnWidth(a)
  4413. },
  4414. fitColumns : function(b) {
  4415. var a = 0;
  4416. if (this.orientation === "horizontal") {
  4417. a = this.getFittingColumnWidth()
  4418. } else {
  4419. a = Math.floor((this.panel.getWidth()
  4420. - Ext.getScrollbarSize().width - 1)
  4421. / this.headerCt.getColumnCount())
  4422. }
  4423. this.setColumnWidth(a, b)
  4424. },
  4425. getAvailableWidthForSchedule : function() {
  4426. var c = (this.lastBox && this.lastBox.width) || this.getWidth();
  4427. var a = this.headerCt.items.items;
  4428. for (var b = 1; b < a.length; b++) {
  4429. c -= a[b].getWidth()
  4430. }
  4431. return c - Ext.getScrollbarSize().width - 1
  4432. },
  4433. getRightColumnsWidth : function() {
  4434. var c = 0;
  4435. var a = this.headerCt.items.items;
  4436. for (var b = 1; b < a.length; b++) {
  4437. c += a[b].getWidth()
  4438. }
  4439. return c
  4440. },
  4441. fixRightColumnsPositions : function() {
  4442. var a = this.headerCt.items.items;
  4443. var c = a[0].getWidth();
  4444. for (var b = 1; b < a.length; b++) {
  4445. var d = a[b];
  4446. d.el.setLeft(c);
  4447. c += d.getWidth()
  4448. }
  4449. },
  4450. getElementFromEventRecord : function(a) {
  4451. return Ext.get(this.eventPrefix + a.internalId)
  4452. },
  4453. getEventNodeByRecord : function(a) {
  4454. return document.getElementById(this.eventPrefix + a.internalId)
  4455. },
  4456. getOuterElementFromEventRecord : function(a) {
  4457. return Ext.get(this.eventPrefix + a.internalId)
  4458. },
  4459. resolveColumnIndex : function(a) {
  4460. return Math.floor(a / this.getActualTimeColumnWidth())
  4461. },
  4462. getStartEndDatesFromRegion : function(b, a) {
  4463. throw "Must be implemented by horizontal/vertical"
  4464. },
  4465. setupTooltip : function() {
  4466. var b = this, a = Ext.apply({
  4467. renderTo : Ext.getBody(),
  4468. delegate : b.eventSelector,
  4469. target : b.el,
  4470. anchor : "b"
  4471. }, b.tipCfg);
  4472. b.tip = Ext.create("Ext.ToolTip", a);
  4473. b.tip.on({
  4474. beforeshow : function(d) {
  4475. if (!d.triggerElement || !d.triggerElement.id) {
  4476. return false
  4477. }
  4478. var c = this.resolveEventRecord(d.triggerElement);
  4479. if (!c
  4480. || this.fireEvent("beforetooltipshow", this, c) === false) {
  4481. return false
  4482. }
  4483. d.update(this.tooltipTpl.apply(this.getDataForTooltipTpl(c)));
  4484. return true
  4485. },
  4486. scope : this
  4487. })
  4488. },
  4489. getDataForTooltipTpl : function(a) {
  4490. return a.data
  4491. },
  4492. getTimeResolution : function() {
  4493. return this.timeAxis.getResolution()
  4494. },
  4495. setTimeResolution : function(b, a) {
  4496. this.timeAxis.setResolution(b, a);
  4497. if (this.snapToIncrement) {
  4498. this.refreshKeepingScroll()
  4499. }
  4500. },
  4501. getEventIdFromDomNodeId : function(a) {
  4502. return a.substring(this.eventPrefix.length)
  4503. },
  4504. getDateFromDomEvent : function(b, a) {
  4505. return this.getDateFromXY(b.getXY(), a)
  4506. },
  4507. handleScheduleEvent : function(c) {
  4508. var b = c.getTarget("." + this.timeCellCls, 2);
  4509. if (b) {
  4510. var a = this.getDateFromDomEvent(c, "floor");
  4511. this.fireEvent("schedule" + c.type, this, a, this.indexOf(this
  4512. .findItemByChild(b)), c)
  4513. }
  4514. },
  4515. setupTimeCellEvents : function() {
  4516. this.mon(this.el, {
  4517. click : this.handleScheduleEvent,
  4518. dblclick : this.handleScheduleEvent,
  4519. contextmenu : this.handleScheduleEvent,
  4520. scope : this
  4521. }, this)
  4522. },
  4523. getSnapPixelAmount : function() {
  4524. if (this.snapToIncrement) {
  4525. var a = this.timeAxis.getResolution();
  4526. return (a.increment || 1) * this.getSingleUnitInPixels(a.unit)
  4527. } else {
  4528. return 1
  4529. }
  4530. },
  4531. getActualTimeColumnWidth : function() {
  4532. return this.headerCt.items.get(0).getTimeColumnWidth()
  4533. },
  4534. setSnapEnabled : function(a) {
  4535. this.snapToIncrement = a;
  4536. if (a) {
  4537. this.refreshKeepingScroll()
  4538. }
  4539. },
  4540. setReadOnly : function(a) {
  4541. this.readOnly = a;
  4542. this[a ? "addCls" : "removeCls"](this._cmpCls + "-readonly")
  4543. },
  4544. isReadOnly : function() {
  4545. return this.readOnly
  4546. },
  4547. setOrientation : function(a) {
  4548. this.orientation = a;
  4549. Ext.apply(this, Sch.view[Ext.String.capitalize(a)].prototype.props)
  4550. },
  4551. getOrientation : function() {
  4552. return this.orientation
  4553. },
  4554. translateToScheduleCoordinate : function(a) {
  4555. throw "Abstract method call!"
  4556. },
  4557. translateToPageCoordinate : function(a) {
  4558. throw "Abstract method call!"
  4559. },
  4560. getDateFromXY : function(c, b, a) {
  4561. throw "Abstract method call!"
  4562. },
  4563. getXYFromDate : function(a, b) {
  4564. throw "Abstract method call!"
  4565. },
  4566. getTimeSpanRegion : function(a, b) {
  4567. throw "Abstract method call!"
  4568. },
  4569. getStart : function() {
  4570. return this.timeAxis.getStart()
  4571. },
  4572. getEnd : function() {
  4573. return this.timeAxis.getEnd()
  4574. },
  4575. setBarMargin : function(b, a) {
  4576. this.barMargin = b;
  4577. if (!a) {
  4578. this.refreshKeepingScroll()
  4579. }
  4580. },
  4581. setRowHeight : function(a, b) {
  4582. this.rowHeight = a || 24;
  4583. if (this.rendered && !b) {
  4584. this.refreshKeepingScroll()
  4585. }
  4586. },
  4587. refreshKeepingScroll : function(a) {
  4588. this.saveScrollState();
  4589. if (this.lightRefresh) {
  4590. this.lightRefresh()
  4591. } else {
  4592. this.refresh()
  4593. }
  4594. this.restoreScrollState()
  4595. },
  4596. refreshKeepingResourceScroll : function(c) {
  4597. var d = this.el.dom, b = d.scrollTop, a = d.scrollLeft;
  4598. if (this.lightRefresh) {
  4599. this.lightRefresh()
  4600. } else {
  4601. this.refresh()
  4602. }
  4603. if (this.getOrientation() === "horizontal") {
  4604. d.scrollTop = b
  4605. } else {
  4606. d.scrollLeft = a
  4607. }
  4608. },
  4609. lightRefresh : function() {
  4610. var a = this.refreshSize;
  4611. Ext.suspendLayouts();
  4612. this.refreshSize = Ext.emptyFn;
  4613. this.__lightRefresh = true;
  4614. this.refresh();
  4615. delete this.__lightRefresh;
  4616. this.refreshSize = a;
  4617. Ext.resumeLayouts()
  4618. }
  4619. }, function() {
  4620. Ext.apply(Sch, {
  4621. VERSION : "2.1.11"
  4622. })
  4623. });
  4624. Ext.define("Sch.view.Horizontal", {
  4625. props : {
  4626. translateToScheduleCoordinate : function(a) {
  4627. return a - this.el.getX() + this.el.getScroll().left
  4628. },
  4629. translateToPageCoordinate : function(a) {
  4630. return a + this.el.getX() - this.el.getScroll().left
  4631. },
  4632. getDateFromXY : function(h, f, e) {
  4633. var b, a = e ? h[0] : this.translateToScheduleCoordinate(h[0]), d = a
  4634. / this.getActualTimeColumnWidth(), c = this.timeAxis
  4635. .getCount();
  4636. if (d < 0 || d > c) {
  4637. b = null
  4638. } else {
  4639. var g = d - this.resolveColumnIndex(a);
  4640. if (g > 2 && d >= c) {
  4641. return null
  4642. }
  4643. b = this.timeAxis.getDateFromTick(d, f)
  4644. }
  4645. return b
  4646. },
  4647. getXYFromDate : function(b, d) {
  4648. var a, c = this.timeAxis.getTickFromDate(b);
  4649. if (c >= 0) {
  4650. a = this.getActualTimeColumnWidth() * c
  4651. }
  4652. if (d === false) {
  4653. a = this.translateToPageCoordinate(a)
  4654. }
  4655. return [Math.round(a), 0]
  4656. },
  4657. getEventBox : function(e, b) {
  4658. var a = Math.floor(this.getXYFromDate(e)[0]), c = Math.floor(this
  4659. .getXYFromDate(b)[0]), d = Math;
  4660. if (this.managedEventSizing) {
  4661. return {
  4662. top : Math.max(0, (this.barMargin
  4663. - (Ext.isIE && !Ext.isStrict)
  4664. ? 0
  4665. : this.eventBorderWidth
  4666. - this.cellBorderWidth)),
  4667. left : d.min(a, c),
  4668. width : d.max(1, d.abs(a - c) - this.eventBorderWidth),
  4669. height : this.rowHeight - (2 * this.barMargin)
  4670. - this.eventBorderWidth
  4671. }
  4672. }
  4673. return {
  4674. left : d.min(a, c),
  4675. width : d.max(1, d.abs(a - c))
  4676. }
  4677. },
  4678. layoutEvents : function(a) {
  4679. var c = Ext.Array.clone(a);
  4680. c.sort(this.sortEvents);
  4681. var b = this.layoutEventsInBands(0, c);
  4682. return b
  4683. },
  4684. layoutEventsInBands : function(d, a) {
  4685. var c = a[0], b = d === 0
  4686. ? this.barMargin
  4687. : (d * this.rowHeight - ((d - 1) * this.barMargin));
  4688. if (b >= this.cellBorderWidth) {
  4689. b -= this.cellBorderWidth
  4690. }
  4691. while (c) {
  4692. c.top = b;
  4693. Ext.Array.remove(a, c);
  4694. c = this.findClosestSuccessor(c, a)
  4695. }
  4696. d++;
  4697. if (a.length > 0) {
  4698. return this.layoutEventsInBands(d, a)
  4699. } else {
  4700. return d
  4701. }
  4702. },
  4703. getScheduleRegion : function(d, f) {
  4704. var h = d ? Ext.fly(this.getNodeByRecord(d)).getRegion() : this.el
  4705. .down(".x-grid-table").getRegion(), e = this.timeAxis
  4706. .getStart(), j = this.timeAxis.getEnd(), b = this
  4707. .getDateConstraints(d, f)
  4708. || {
  4709. start : e,
  4710. end : j
  4711. }, c = this.translateToPageCoordinate(this
  4712. .getXYFromDate(b.start)[0]), i = this
  4713. .translateToPageCoordinate(this.getXYFromDate(b.end)[0])
  4714. - this.eventBorderWidth, g = h.top + this.barMargin, a = h.bottom
  4715. - this.barMargin - this.eventBorderWidth;
  4716. return new Ext.util.Region(g, Math.max(c, i), a, Math.min(c, i))
  4717. },
  4718. getResourceRegion : function(h, d, g) {
  4719. var k = Ext.fly(this.getNodeByRecord(h)).getRegion(), i = this.timeAxis
  4720. .getStart(), n = this.timeAxis.getEnd(), c = d
  4721. ? Sch.util.Date.max(i, d)
  4722. : i, e = g ? Sch.util.Date.min(n, g) : n, f = this
  4723. .getXYFromDate(c)[0], m = this.getXYFromDate(e)[0]
  4724. - this.eventBorderWidth, l = this.el.getTop(), b = this.el
  4725. .getScroll(), j = k.top + 1 - l + b.top, a = k.bottom - 1
  4726. - l + b.top;
  4727. return new Ext.util.Region(j, Math.max(f, m), a, Math.min(f, m))
  4728. },
  4729. collectRowData : function(g, p, o) {
  4730. var c = this.eventStore.getEventsForResource(p);
  4731. if (c.length === 0 || this.headerCt.getColumnCount() === 0) {
  4732. g.rowHeight = this.rowHeight;
  4733. return g
  4734. }
  4735. var a = Sch.util.Date, m = this.timeAxis, n = m.getStart(), r = m
  4736. .getEnd(), k = [], j, f;
  4737. for (j = 0, f = c.length; j < f; j++) {
  4738. var b = c[j], d = b.getStartDate(), h = b.getEndDate();
  4739. if (d && h && m.timeSpanInAxis(d, h)) {
  4740. var q = this.generateTplData(b, n, r, p, o);
  4741. k[k.length] = q
  4742. }
  4743. }
  4744. var e = 1;
  4745. if (this.dynamicRowHeight) {
  4746. e = this.layoutEvents(k)
  4747. }
  4748. g.rowHeight = (e * this.rowHeight) - ((e - 1) * this.barMargin);
  4749. g[this.getFirstTimeColumn().id] += "&#160;"
  4750. + this.eventTpl.apply(k);
  4751. return g
  4752. },
  4753. resolveResource : function(a) {
  4754. var b = this.findItemByChild(a);
  4755. if (b) {
  4756. return this.getRecord(b)
  4757. }
  4758. return null
  4759. },
  4760. getTimeSpanRegion : function(b, h, g) {
  4761. var d = this.getXYFromDate(b)[0], f = this.getXYFromDate(h || b)[0], a, c;
  4762. if (this.store.buffered) {
  4763. var e;
  4764. if (this.panel.verticalScroller.stretcher instanceof Ext.CompositeElement) {
  4765. e = this.panel.verticalScroller.stretcher.first()
  4766. } else {
  4767. e = this.el.down(".x-stretcher")
  4768. }
  4769. if (e.dom.clientHeight) {
  4770. c = e
  4771. }
  4772. }
  4773. if (!c) {
  4774. c = this.el.down(".x-grid-table")
  4775. }
  4776. if (g) {
  4777. a = Math.max(c ? c.dom.clientHeight : 0,
  4778. this.el.dom.clientHeight)
  4779. } else {
  4780. a = c ? c.dom.clientHeight : 0
  4781. }
  4782. return new Ext.util.Region(0, Math.max(d, f), a, Math.min(d, f))
  4783. },
  4784. getStartEndDatesFromRegion : function(c, b) {
  4785. var a = this.getDateFromXY([c.left, 0], b), d = this.getDateFromXY(
  4786. [c.right, 0], b);
  4787. if (d && a) {
  4788. return {
  4789. start : Sch.util.Date.min(a, d),
  4790. end : Sch.util.Date.max(a, d)
  4791. }
  4792. } else {
  4793. return null
  4794. }
  4795. },
  4796. onEventAdd : function(m, h) {
  4797. var e = {};
  4798. for (var g = 0, c = h.length; g < c; g++) {
  4799. var a = h[g].getResources();
  4800. for (var f = 0, d = a.length; f < d; f++) {
  4801. var b = a[f];
  4802. e[b.getId()] = b
  4803. }
  4804. }
  4805. Ext.Object.each(e, function(j, i) {
  4806. this.onUpdate(this.resourceStore, i)
  4807. }, this)
  4808. },
  4809. onEventRemove : function(e, b) {
  4810. var h = b.getResources();
  4811. var f = this.resourceStore;
  4812. var a = Ext.tree.View && this instanceof Ext.tree.View;
  4813. var d = function(i) {
  4814. if (a && this.store.indexOf(i)) {
  4815. this.onUpdate(this.store, i)
  4816. } else {
  4817. if (f.indexOf(i) >= 0) {
  4818. this.onUpdate(f, i)
  4819. }
  4820. }
  4821. };
  4822. if (h.length > 1) {
  4823. Ext.each(h, d, this)
  4824. } else {
  4825. var c = this.getElementFromEventRecord(b);
  4826. if (c) {
  4827. var g = this.resolveResource(c);
  4828. c.fadeOut({
  4829. callback : function() {
  4830. d.call(this, g)
  4831. },
  4832. scope : this
  4833. })
  4834. }
  4835. }
  4836. },
  4837. onEventUpdate : function(b, c, a) {
  4838. var d = c.previous;
  4839. if (d && d[c.resourceIdField]) {
  4840. var e = c.getResource(d[c.resourceIdField]);
  4841. if (e) {
  4842. this.onUpdate(this.resourceStore, e)
  4843. }
  4844. }
  4845. var f = c.getResources();
  4846. Ext.each(f, function(g) {
  4847. this.onUpdate(this.resourceStore, g)
  4848. }, this)
  4849. },
  4850. getSingleTickInPixels : function() {
  4851. return this.getActualTimeColumnWidth()
  4852. },
  4853. getColumnWidth : function() {
  4854. if (this.getTimeAxisColumn()) {
  4855. return this.getTimeAxisColumn().getTimeColumnWidth()
  4856. }
  4857. },
  4858. setColumnWidth : function(b, a) {
  4859. if (this.getTimeAxisColumn()) {
  4860. this.getTimeAxisColumn().setTimeColumnWidth(b);
  4861. if (!a) {
  4862. this.refreshKeepingScroll()
  4863. }
  4864. }
  4865. this.fireEvent("columnwidthchange", this, b)
  4866. },
  4867. getVisibleDateRange : function() {
  4868. if (!this.rendered) {
  4869. return null
  4870. }
  4871. var c = this.getEl().getScroll(), b = this.panel.getStart(), f = this.panel
  4872. .getEnd(), e = this.getWidth(), d = this.getEl()
  4873. .down(".x-grid-table").dom, a = d.clientWidth;
  4874. if (a < e) {
  4875. return {
  4876. startDate : b,
  4877. endDate : f
  4878. }
  4879. }
  4880. return {
  4881. startDate : this.getDateFromXY([c.left, 0], null, true),
  4882. endDate : this.getDateFromXY([Math.min(c.left + e, a), 0],
  4883. null, true)
  4884. }
  4885. }
  4886. }
  4887. });
  4888. Ext.define("Sch.mixin.FilterableTreeView", {
  4889. initTreeFiltering : function() {
  4890. var a = function() {
  4891. var b = this.up("tablepanel").store;
  4892. this.mon(b, "nodestore-datachange-start",
  4893. this.onFilterChangeStart, this);
  4894. this.mon(b, "nodestore-datachange-end",
  4895. this.onFilterChangeEnd, this);
  4896. this.mon(b, "filter-clear", this.onFilterCleared, this);
  4897. this.mon(b, "filter-set", this.onFilterSet, this)
  4898. };
  4899. if (this.rendered) {
  4900. a.call(this)
  4901. } else {
  4902. this.on("beforerender", a, this, {
  4903. single : true
  4904. })
  4905. }
  4906. },
  4907. onFilterChangeStart : function() {
  4908. Ext.suspendLayouts()
  4909. },
  4910. onFilterChangeEnd : function() {
  4911. Ext.resumeLayouts()
  4912. },
  4913. onFilterCleared : function() {
  4914. delete this.toggle;
  4915. var a = this.getEl();
  4916. if (a) {
  4917. a.removeCls("sch-tree-filtered")
  4918. }
  4919. },
  4920. onFilterSet : function() {
  4921. this.toggle = function() {
  4922. };
  4923. var a = this.getEl();
  4924. if (a) {
  4925. a.addCls("sch-tree-filtered")
  4926. }
  4927. }
  4928. });
  4929. Ext.define("Sch.view.TimelineTreeView", {
  4930. extend : "Ext.tree.View",
  4931. mixins : ["Sch.mixin.TimelineView", "Sch.mixin.FilterableTreeView"],
  4932. requires : ["Sch.patches.TreeView"],
  4933. cellBorderWidth : 0,
  4934. constructor : function() {
  4935. this.callParent(arguments);
  4936. this.initTreeFiltering()
  4937. }
  4938. }, function() {
  4939. this
  4940. .override(Sch.mixin.TimelineView.prototype.inheritables()
  4941. || {})
  4942. });
  4943. Ext.define("Sch.mixin.Zoomable", {
  4944. zoomLevels : [{
  4945. width : 30,
  4946. increment : 1,
  4947. resolution : 1,
  4948. preset : "year",
  4949. resolutionUnit : "MONTH"
  4950. }, {
  4951. width : 50,
  4952. increment : 1,
  4953. resolution : 1,
  4954. preset : "year",
  4955. resolutionUnit : "MONTH"
  4956. }, {
  4957. width : 100,
  4958. increment : 1,
  4959. resolution : 1,
  4960. preset : "year",
  4961. resolutionUnit : "MONTH"
  4962. }, {
  4963. width : 200,
  4964. increment : 1,
  4965. resolution : 1,
  4966. preset : "year",
  4967. resolutionUnit : "MONTH"
  4968. }, {
  4969. width : 100,
  4970. increment : 1,
  4971. resolution : 7,
  4972. preset : "monthAndYear",
  4973. resolutionUnit : "DAY"
  4974. }, {
  4975. width : 30,
  4976. increment : 1,
  4977. resolution : 1,
  4978. preset : "weekDateAndMonth",
  4979. resolutionUnit : "DAY"
  4980. }, {
  4981. width : 35,
  4982. increment : 1,
  4983. resolution : 1,
  4984. preset : "weekAndMonth",
  4985. resolutionUnit : "DAY"
  4986. }, {
  4987. width : 50,
  4988. increment : 1,
  4989. resolution : 1,
  4990. preset : "weekAndMonth",
  4991. resolutionUnit : "DAY"
  4992. }, {
  4993. width : 20,
  4994. increment : 1,
  4995. resolution : 1,
  4996. preset : "weekAndDayLetter"
  4997. }, {
  4998. width : 50,
  4999. increment : 1,
  5000. resolution : 1,
  5001. preset : "weekAndDay",
  5002. resolutionUnit : "HOUR"
  5003. }, {
  5004. width : 100,
  5005. increment : 1,
  5006. resolution : 1,
  5007. preset : "weekAndDay",
  5008. resolutionUnit : "HOUR"
  5009. }, {
  5010. width : 50,
  5011. increment : 6,
  5012. resolution : 30,
  5013. preset : "hourAndDay",
  5014. resolutionUnit : "MINUTE"
  5015. }, {
  5016. width : 100,
  5017. increment : 6,
  5018. resolution : 30,
  5019. preset : "hourAndDay",
  5020. resolutionUnit : "MINUTE"
  5021. }, {
  5022. width : 60,
  5023. increment : 2,
  5024. resolution : 30,
  5025. preset : "hourAndDay",
  5026. resolutionUnit : "MINUTE"
  5027. }, {
  5028. width : 60,
  5029. increment : 1,
  5030. resolution : 30,
  5031. preset : "hourAndDay",
  5032. resolutionUnit : "MINUTE"
  5033. }, {
  5034. width : 30,
  5035. increment : 15,
  5036. resolution : 5,
  5037. preset : "minuteAndHour"
  5038. }, {
  5039. width : 60,
  5040. increment : 15,
  5041. resolution : 5,
  5042. preset : "minuteAndHour"
  5043. }, {
  5044. width : 130,
  5045. increment : 15,
  5046. resolution : 5,
  5047. preset : "minuteAndHour"
  5048. }, {
  5049. width : 60,
  5050. increment : 5,
  5051. resolution : 5,
  5052. preset : "minuteAndHour"
  5053. }, {
  5054. width : 100,
  5055. increment : 5,
  5056. resolution : 5,
  5057. preset : "minuteAndHour"
  5058. }],
  5059. minZoomLevel : null,
  5060. maxZoomLevel : null,
  5061. visibleZoomFactor : 5,
  5062. cachedCenterDate : null,
  5063. isFirstZoom : true,
  5064. isZooming : false,
  5065. initializeZooming : function() {
  5066. this.zoomLevels = this.zoomLevels.slice();
  5067. this.setMinZoomLevel(this.minZoomLevel || 0);
  5068. this.setMaxZoomLevel(this.maxZoomLevel !== null
  5069. ? this.maxZoomLevel
  5070. : this.zoomLevels.length - 1);
  5071. this.on("viewchange", this.clearCenterDateCache, this)
  5072. },
  5073. getZoomLevelUnit : function(b) {
  5074. var a = Sch.preset.Manager.getPreset(b.preset).headerConfig;
  5075. return a.bottom ? a.bottom.unit : a.middle.unit
  5076. },
  5077. getMilliSecondsPerPixelForZoomLevel : function(b) {
  5078. var a = Sch.util.Date;
  5079. return Math.round((a.add(new Date(1, 0, 1), this.getZoomLevelUnit(b),
  5080. b.increment) - new Date(1, 0, 1))
  5081. / b.width)
  5082. },
  5083. presetToZoomLevel : function(e) {
  5084. var d = Sch.preset.Manager.getPreset(e);
  5085. var c = d.headerConfig;
  5086. var a = c.bottom;
  5087. var b = c.middle;
  5088. return {
  5089. preset : e,
  5090. increment : (a ? a.increment : b.increment) || 1,
  5091. resolution : d.timeResolution.increment,
  5092. resolutionUnit : d.timeResolution.unit,
  5093. width : d.timeColumnWidth
  5094. }
  5095. },
  5096. calculateCurrentZoomLevel : function() {
  5097. var d = this.presetToZoomLevel(this.viewPreset);
  5098. var c = this.timeAxis.headerConfig;
  5099. var a = c.bottom;
  5100. var b = c.middle;
  5101. d.width = this.timeAxis.preset.timeColumnWidth;
  5102. d.increment = (a ? a.increment : b.increment) || 1;
  5103. return d
  5104. },
  5105. getCurrentZoomLevelIndex : function() {
  5106. var f = this.calculateCurrentZoomLevel();
  5107. var b = this.getMilliSecondsPerPixelForZoomLevel(f);
  5108. var e = this.zoomLevels;
  5109. for (var c = 0; c < e.length; c++) {
  5110. var d = this.getMilliSecondsPerPixelForZoomLevel(e[c]);
  5111. if (d == b) {
  5112. return c
  5113. }
  5114. if (c === 0 && b > d) {
  5115. return -0.5
  5116. }
  5117. if (c == e.length - 1 && b < d) {
  5118. return e.length - 1 + 0.5
  5119. }
  5120. var a = this.getMilliSecondsPerPixelForZoomLevel(e[c + 1]);
  5121. if (d > b && b > a) {
  5122. return c + 0.5
  5123. }
  5124. }
  5125. throw "Can't find current zoom level index"
  5126. },
  5127. setMaxZoomLevel : function(a) {
  5128. if (a < 0 || a >= this.zoomLevels.length) {
  5129. throw new Error("Invalid range for `setMinZoomLevel`")
  5130. }
  5131. this.maxZoomLevel = a
  5132. },
  5133. setMinZoomLevel : function(a) {
  5134. if (a < 0 || a >= this.zoomLevels.length) {
  5135. throw new Error("Invalid range for `setMinZoomLevel`")
  5136. }
  5137. this.minZoomLevel = a
  5138. },
  5139. getViewportCenterDateCached : function() {
  5140. if (this.cachedCenterDate) {
  5141. return this.cachedCenterDate
  5142. }
  5143. return this.cachedCenterDate = this.getViewportCenterDate()
  5144. },
  5145. clearCenterDateCache : function() {
  5146. this.cachedCenterDate = null
  5147. },
  5148. zoomToLevel : function(b) {
  5149. b = Ext.Number.constrain(b, this.minZoomLevel, this.maxZoomLevel);
  5150. var n = this.calculateCurrentZoomLevel();
  5151. var d = this.getMilliSecondsPerPixelForZoomLevel(n);
  5152. var i = this.zoomLevels[b];
  5153. var a = this.getMilliSecondsPerPixelForZoomLevel(i);
  5154. if (d == a) {
  5155. return null
  5156. }
  5157. var p = this;
  5158. var j = this.getSchedulingView();
  5159. var f = j.getEl();
  5160. if (this.isFirstZoom) {
  5161. this.isFirstZoom = false;
  5162. f.on("scroll", this.clearCenterDateCache, this)
  5163. }
  5164. var h = this.orientation == "vertical";
  5165. var e = this.getViewportCenterDateCached();
  5166. var k = h ? f.getHeight() : f.getWidth();
  5167. var l = Ext.clone(Sch.preset.Manager.getPreset(i.preset));
  5168. var o = this.calculateOptimalDateRange(e, k, i);
  5169. var c = l.headerConfig;
  5170. var g = c.bottom;
  5171. var r = c.middle;
  5172. l[h ? "rowHeight" : "timeColumnWidth"] = i.width;
  5173. if (g) {
  5174. g.increment = i.increment
  5175. } else {
  5176. r.increment = i.increment
  5177. }
  5178. this.isZooming = true;
  5179. this.viewPreset = i.preset;
  5180. var m = g ? g.unit : r.unit;
  5181. this.timeAxis.reconfigure({
  5182. preset : l,
  5183. headerConfig : c,
  5184. unit : m,
  5185. increment : i.increment,
  5186. resolutionUnit : Sch.util.Date.getUnitByName(i.resolutionUnit || m),
  5187. resolutionIncrement : i.resolution,
  5188. weekStartDay : this.weekStartDay,
  5189. mainUnit : r.unit,
  5190. shiftUnit : l.shiftUnit,
  5191. shiftIncrement : l.shiftIncrement || 1,
  5192. defaultSpan : l.defaultSpan || 1,
  5193. start : o.startDate || this.getStart(),
  5194. end : o.endDate || this.getEnd()
  5195. });
  5196. var q = j.getXYFromDate(e, true);
  5197. f.on("scroll", function() {
  5198. p.cachedCenterDate = e
  5199. }, this, {
  5200. single : true
  5201. });
  5202. if (h) {
  5203. f.scrollTo("top", q[1] - k / 2)
  5204. } else {
  5205. f.scrollTo("left", q[0] - k / 2)
  5206. }
  5207. p.isZooming = false;
  5208. this.fireEvent("zoomchange", this, b);
  5209. return b
  5210. },
  5211. zoomIn : function(a) {
  5212. a = a || 1;
  5213. var b = this.getCurrentZoomLevelIndex();
  5214. if (b >= this.zoomLevels.length - 1) {
  5215. return null
  5216. }
  5217. return this.zoomToLevel(Math.floor(b) + a)
  5218. },
  5219. zoomOut : function(a) {
  5220. a = a || 1;
  5221. var b = this.getCurrentZoomLevelIndex();
  5222. if (b <= 0) {
  5223. return null
  5224. }
  5225. return this.zoomToLevel(Math.ceil(b) - a)
  5226. },
  5227. zoomInFull : function() {
  5228. return this.zoomToLevel(this.maxZoomLevel)
  5229. },
  5230. zoomOutFull : function() {
  5231. return this.zoomToLevel(this.minZoomLevel)
  5232. },
  5233. calculateOptimalDateRange : function(c, h, e) {
  5234. var b = Sch.util.Date;
  5235. var i = Sch.preset.Manager.getPreset(e.preset).headerConfig;
  5236. var f = i.top ? i.top.unit : i.middle.unit;
  5237. var j = this.getZoomLevelUnit(e);
  5238. var d = Math.ceil(h / e.width * e.increment * this.visibleZoomFactor
  5239. / 2);
  5240. var a = b.add(c, j, -d);
  5241. var g = b.add(c, j, d);
  5242. return {
  5243. startDate : this.timeAxis.floorDate(a, false, f),
  5244. endDate : this.timeAxis.ceilDate(g, false, f)
  5245. }
  5246. }
  5247. });
  5248. Ext.define("Sch.mixin.TimelinePanel", {
  5249. requires : ["Sch.util.Patch", "Sch.patches.LoadMask", "Sch.patches.Model",
  5250. "Sch.patches.Table", "Sch.data.TimeAxis",
  5251. "Sch.feature.ColumnLines", "Sch.view.Locking",
  5252. "Sch.mixin.Lockable", "Sch.preset.Manager"],
  5253. mixins : ["Sch.mixin.Zoomable"],
  5254. orientation : "horizontal",
  5255. weekStartDay : 1,
  5256. snapToIncrement : false,
  5257. readOnly : false,
  5258. eventResizeHandles : "both",
  5259. viewPreset : "weekAndDay",
  5260. trackHeaderOver : true,
  5261. startDate : null,
  5262. endDate : null,
  5263. eventBorderWidth : 1,
  5264. tooltipTpl : null,
  5265. tipCfg : {
  5266. cls : "sch-tip",
  5267. showDelay : 1000,
  5268. hideDelay : 0,
  5269. autoHide : true,
  5270. anchor : "b"
  5271. },
  5272. lightWeight : true,
  5273. timeCellRenderer : null,
  5274. timeCellRendererScope : null,
  5275. inheritables : function() {
  5276. return {
  5277. columnLines : true,
  5278. enableColumnMove : false,
  5279. enableLocking : true,
  5280. lockable : true,
  5281. lockedXType : null,
  5282. normalXType : null,
  5283. initComponent : function() {
  5284. this.lightWeight = this.lightWeight && !this.timeCellRenderer;
  5285. this.addEvents("timeheaderdblclick", "beforeviewchange",
  5286. "viewchange");
  5287. if (!this.timeAxis) {
  5288. this.timeAxis = Ext.create("Sch.data.TimeAxis")
  5289. }
  5290. if (!this.columns && !this.colModel) {
  5291. this.columns = []
  5292. }
  5293. this.timeAxis.on("reconfigure", this.onTimeAxisReconfigure,
  5294. this);
  5295. if (this.enableLocking) {
  5296. this.self.mixin("lockable", Sch.mixin.Lockable);
  5297. var b = 0, a = this.columns.length, c;
  5298. for (; b < a; ++b) {
  5299. c = this.columns[b];
  5300. if (c.locked !== false) {
  5301. c.locked = true
  5302. }
  5303. c.lockable = false
  5304. }
  5305. this.switchViewPreset(this.viewPreset, this.startDate
  5306. || this.timeAxis.getStart(), this.endDate
  5307. || this.timeAxis.getEnd(), true)
  5308. }
  5309. this.callParent(arguments);
  5310. if (this.lockable) {
  5311. this.applyViewSettings(this.timeAxis.preset);
  5312. if (!this.viewPreset) {
  5313. throw "You must define a valid view preset object. See Sch.preset.Manager class for reference"
  5314. }
  5315. if (this.lightWeight && this.columnLines) {
  5316. this.columnLinesFeature = new Sch.feature.ColumnLines();
  5317. this.columnLinesFeature.init(this)
  5318. }
  5319. }
  5320. this.initializeZooming();
  5321. this.relayEvents(this.getView(), ["beforetooltipshow",
  5322. "scheduleclick", "scheduledblclick",
  5323. "schedulecontextmenu"])
  5324. },
  5325. getState : function() {
  5326. var a = this, b = a.callParent(arguments);
  5327. Ext.apply(b, {
  5328. viewPreset : a.viewPreset,
  5329. startDate : a.getStart(),
  5330. endDate : a.getEnd(),
  5331. zoomMinLevel : a.zoomMinLevel,
  5332. zoomMaxLevel : a.zoomMaxLevel,
  5333. currentZoomLevel : a.currentZoomLevel
  5334. });
  5335. return b
  5336. },
  5337. getOrientation : function() {
  5338. return this.orientation
  5339. },
  5340. applyState : function(b) {
  5341. var a = this;
  5342. a.callParent(arguments);
  5343. if (b && b.viewPreset) {
  5344. a.switchViewPreset(b.viewPreset, b.startDate, b.endDate)
  5345. }
  5346. if (b && b.currentZoomLevel) {
  5347. a.zoomToLevel(b.currentZoomLevel)
  5348. }
  5349. },
  5350. beforeRender : function() {
  5351. this.callParent(arguments);
  5352. if (this.lockable) {
  5353. this.addCls("sch-" + this.orientation)
  5354. }
  5355. },
  5356. afterRender : function() {
  5357. this.callParent(arguments);
  5358. if (this.lockable) {
  5359. this.lockedGrid.on("itemdblclick", function(d, c, e, g, f) {
  5360. if (this.orientation == "vertical" && c) {
  5361. this.fireEvent("timeheaderdblclick", this,
  5362. c.get("start"), c.get("end"), g, f)
  5363. }
  5364. }, this)
  5365. } else {
  5366. var b = this.headerCt;
  5367. if (b && b.reorderer && b.reorderer.dropZone) {
  5368. var a = b.reorderer.dropZone;
  5369. a.positionIndicator = Ext.Function.createSequence(
  5370. a.positionIndicator, function() {
  5371. this.valid = false
  5372. })
  5373. }
  5374. }
  5375. },
  5376. delayScroll : function() {
  5377. var a = this.getScrollTarget().el;
  5378. if (a) {
  5379. this.scrollTask.delay(10, function() {
  5380. if (a.dom) {
  5381. this.syncHorizontalScroll(a.dom.scrollLeft)
  5382. }
  5383. }, this)
  5384. }
  5385. }
  5386. }
  5387. },
  5388. setReadOnly : function(a) {
  5389. this.getSchedulingView().setReadOnly(a)
  5390. },
  5391. isReadOnly : function() {
  5392. return this.getSchedulingView().isReadOnly()
  5393. },
  5394. switchViewPreset : function(d, a, f, b) {
  5395. if (this.fireEvent("beforeviewchange", this, d, a, f) !== false) {
  5396. if (Ext.isString(d)) {
  5397. this.viewPreset = d;
  5398. d = Sch.preset.Manager.getPreset(d)
  5399. }
  5400. if (!d) {
  5401. throw "View preset not found"
  5402. }
  5403. var e = d.headerConfig;
  5404. var c = {
  5405. unit : e.bottom ? e.bottom.unit : e.middle.unit,
  5406. increment : (e.bottom ? e.bottom.increment : e.middle.increment)
  5407. || 1,
  5408. resolutionUnit : d.timeResolution.unit,
  5409. resolutionIncrement : d.timeResolution.increment,
  5410. weekStartDay : this.weekStartDay,
  5411. mainUnit : e.middle.unit,
  5412. shiftUnit : d.shiftUnit,
  5413. headerConfig : d.headerConfig,
  5414. shiftIncrement : d.shiftIncrement || 1,
  5415. preset : d,
  5416. defaultSpan : d.defaultSpan || 1
  5417. };
  5418. if (b) {
  5419. if (this.timeAxis.getCount() === 0 || a) {
  5420. c.start = a || new Date();
  5421. c.end = f
  5422. }
  5423. } else {
  5424. c.start = a || this.timeAxis.getStart();
  5425. c.end = f
  5426. }
  5427. if (!b) {
  5428. this.applyViewSettings(d)
  5429. }
  5430. this.timeAxis.reconfigure(c)
  5431. }
  5432. },
  5433. applyViewSettings : function(b) {
  5434. var a = this.getSchedulingView();
  5435. a.setDisplayDateFormat(b.displayDateFormat);
  5436. if (this.orientation === "horizontal") {
  5437. a.setRowHeight(this.rowHeight || b.rowHeight, true)
  5438. }
  5439. },
  5440. getStart : function() {
  5441. return this.timeAxis.getStart()
  5442. },
  5443. getEnd : function() {
  5444. return this.timeAxis.getEnd()
  5445. },
  5446. getViewportCenterDate : function() {
  5447. var b = this.getSchedulingView(), c = b.getEl(), a = c.getScroll(), d;
  5448. if (this.orientation === "vertical") {
  5449. d = [0, a.top + c.getHeight() / 2]
  5450. } else {
  5451. d = [a.left + c.getWidth() / 2, 0]
  5452. }
  5453. return b.getDateFromXY(d, null, true)
  5454. },
  5455. setTimeColumnWidth : function(b, a) {
  5456. this.getSchedulingView().setColumnWidth(b, a)
  5457. },
  5458. onTimeAxisReconfigure : function() {
  5459. this.fireEvent("viewchange", this);
  5460. if (this.stateful && this.lockedGrid) {
  5461. this.saveState()
  5462. }
  5463. },
  5464. getColumnsState : function() {
  5465. var b = this, a = b.lockedGrid.headerCt.getColumnsState();
  5466. return a
  5467. },
  5468. shiftNext : function(a) {
  5469. this.timeAxis.shiftNext(a)
  5470. },
  5471. shiftPrevious : function(a) {
  5472. this.timeAxis.shiftPrevious(a)
  5473. },
  5474. goToNow : function() {
  5475. this.setTimeSpan(new Date())
  5476. },
  5477. setTimeSpan : function(b, a) {
  5478. if (this.timeAxis) {
  5479. this.timeAxis.setTimeSpan(b, a)
  5480. }
  5481. },
  5482. setStart : function(a) {
  5483. this.setTimeSpan(a)
  5484. },
  5485. setEnd : function(a) {
  5486. this.setTimeSpan(null, a)
  5487. },
  5488. getTimeAxis : function() {
  5489. return this.timeAxis
  5490. },
  5491. getResourceByEventRecord : function(a) {
  5492. return a.getResource()
  5493. },
  5494. scrollToDate : function(c, b) {
  5495. var a = this.getSchedulingView(), d = a.getXYFromDate(c, true);
  5496. if (this.orientation == "horizontal") {
  5497. a.getEl().scrollTo("left", Math.max(0, d[0]), b)
  5498. } else {
  5499. a.getEl().scrollTo("top", Math.max(0, d[1]), b)
  5500. }
  5501. },
  5502. getSchedulingView : function() {
  5503. return this.lockable ? this.normalGrid.getView() : this.getView()
  5504. },
  5505. setOrientation : function(a) {
  5506. this.removeCls("sch-" + this.orientation);
  5507. this.addCls("sch-" + a);
  5508. this.orientation = a
  5509. }
  5510. });
  5511. Ext.define("Sch.panel.TimelineTreePanel", {
  5512. extend : "Ext.tree.Panel",
  5513. requires : ["Ext.data.TreeStore"],
  5514. mixins : ["Sch.mixin.TimelinePanel"],
  5515. useArrows : true,
  5516. rootVisible : false,
  5517. constructor : function(a) {
  5518. a = a || {};
  5519. a.animate = false;
  5520. this.callParent(arguments)
  5521. },
  5522. initComponent : function() {
  5523. this.callParent(arguments);
  5524. if (this.lockable
  5525. && this.lockedGrid.headerCt.query("treecolumn").length === 0) {
  5526. Ext.Error
  5527. .raise("You must define an Ext.tree.Column (or use xtype : 'treecolumn').")
  5528. }
  5529. },
  5530. onRootChange : function(a) {
  5531. if (!this.lockable) {
  5532. this.callParent(arguments)
  5533. }
  5534. },
  5535. bindStore : function(b) {
  5536. this.callParent(arguments);
  5537. if (Ext.getVersion("extjs").isGreaterThanOrEqual("4.1.2")) {
  5538. var c = this, a = c.getView();
  5539. if (b.buffered && c.verticalScroll) {
  5540. c.verticalScroller = new Ext.grid.PagingScroller(Ext.apply({
  5541. panel : c,
  5542. store : b,
  5543. view : c.view
  5544. }, c.initialConfig.verticalScroller))
  5545. }
  5546. if (b && b.buffered) {
  5547. a.preserveScrollOnRefresh = true
  5548. } else {
  5549. if (c.invalidateScrollerOnRefresh !== undefined) {
  5550. a.preserveScrollOnRefresh = !c.invalidateScrollerOnRefresh
  5551. }
  5552. }
  5553. }
  5554. }
  5555. }, function() {
  5556. this.override(Sch.mixin.TimelinePanel.prototype.inheritables() || {})
  5557. });
  5558. Ext.define("Sch.plugin.Printable", {
  5559. extend : "Ext.AbstractPlugin",
  5560. lockableScope : "top",
  5561. docType : "<!DOCTYPE HTML>",
  5562. beforePrint : Ext.emptyFn,
  5563. afterPrint : Ext.emptyFn,
  5564. autoPrintAndClose : true,
  5565. fakeBackgroundColor : true,
  5566. scheduler : null,
  5567. constructor : function(a) {
  5568. Ext.apply(this, a)
  5569. },
  5570. init : function(a) {
  5571. this.scheduler = a;
  5572. a.print = Ext.Function.bind(this.print, this)
  5573. },
  5574. mainTpl : new Ext.XTemplate(
  5575. '{docType}<html class="x-border-box {htmlClasses}"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /><title>{title}</title>{styles}</head><body class="sch-print-body {bodyClasses}"><div class="sch-print-ct {componentClasses}" style="width:{totalWidth}px"><div class="sch-print-headerbg" style="border-left-width:{totalWidth}px;height:{headerHeight}px;"></div><div class="sch-print-header-wrap">{[this.printLockedHeader(values)]}{[this.printNormalHeader(values)]}</div>{[this.printLockedGrid(values)]}{[this.printNormalGrid(values)]}</div><script type="text/javascript">{setupScript}<\/script></body></html>',
  5576. {
  5577. printLockedHeader : function(a) {
  5578. var b = "";
  5579. if (a.lockedGrid) {
  5580. b += '<div style="left:-' + a.lockedScroll
  5581. + "px;margin-right:-" + a.lockedScroll
  5582. + "px;width:"
  5583. + (a.lockedWidth + a.lockedScroll) + 'px"';
  5584. b += 'class="sch-print-lockedheader x-grid-header-ct x-grid-header-ct-default x-docked x-docked-top x-grid-header-ct-docked-top x-grid-header-ct-default-docked-top x-box-layout-ct x-docked-noborder-top x-docked-noborder-right x-docked-noborder-left">';
  5585. b += a.lockedHeader;
  5586. b += "</div>"
  5587. }
  5588. return b
  5589. },
  5590. printNormalHeader : function(a) {
  5591. var b = "";
  5592. if (a.normalGrid) {
  5593. b += '<div style="left:'
  5594. + (a.lockedGrid ? a.lockedWidth : "0")
  5595. + "px;width:"
  5596. + a.normalWidth
  5597. + 'px;" class="sch-print-normalheader x-grid-header-ct x-grid-header-ct-default x-docked x-docked-top x-grid-header-ct-docked-top x-grid-header-ct-default-docked-top x-box-layout-ct x-docked-noborder-top x-docked-noborder-right x-docked-noborder-left">';
  5598. b += '<div style="margin-left:-' + a.normalScroll
  5599. + 'px">' + a.normalHeader + "</div>";
  5600. b += "</div>"
  5601. }
  5602. return b
  5603. },
  5604. printLockedGrid : function(a) {
  5605. var b = "";
  5606. if (a.lockedGrid) {
  5607. b += '<div id="lockedRowsCt" style="left:-'
  5608. + a.lockedScroll + "px;margin-right:-"
  5609. + a.lockedScroll + "px;width:" + a.lockedWidth
  5610. + a.lockedScroll + "px;top:" + a.headerHeight
  5611. + 'px;" class="sch-print-locked-rows-ct '
  5612. + a.innerLockedClasses
  5613. + ' x-grid-inner-locked">';
  5614. b += a.lockedRows;
  5615. b += "</div>"
  5616. }
  5617. return b
  5618. },
  5619. printNormalGrid : function(a) {
  5620. var b = "";
  5621. if (a.normalGrid) {
  5622. b += '<div id="normalRowsCt" style="left:'
  5623. + (a.lockedGrid ? a.lockedWidth : "0")
  5624. + "px;top:" + a.headerHeight + "px;width:"
  5625. + a.normalWidth
  5626. + 'px" class="sch-print-normal-rows-ct '
  5627. + a.innerNormalClasses + '">';
  5628. b += '<div style="position:relative;overflow:visible;margin-left:-'
  5629. + a.normalScroll
  5630. + 'px">'
  5631. + a.normalRows
  5632. + "</div>";
  5633. b += "</div>"
  5634. }
  5635. return b
  5636. }
  5637. }),
  5638. getGridContent : function(l) {
  5639. var k = l.normalGrid, d = l.lockedGrid, m = d.getView(), e = k
  5640. .getView(), h, c, j, g, i, a, f;
  5641. this.beforePrint(l);
  5642. if (d.collapsed && !k.collapsed) {
  5643. a = d.getWidth() + k.getWidth()
  5644. } else {
  5645. a = k.getWidth();
  5646. f = d.getWidth()
  5647. }
  5648. var b = m.store.getRange();
  5649. c = m.tpl.apply(m.collectData(b, 0));
  5650. j = e.tpl.apply(e.collectData(b, 0));
  5651. g = m.el.getScroll().left;
  5652. i = e.el.getScroll().left;
  5653. if (Sch.feature && Sch.feature.AbstractTimeSpan) {
  5654. Ext.each((l.normalGrid.plugins || []).concat(l.columnLinesFeature
  5655. || []), function(n) {
  5656. if (n instanceof Sch.feature.AbstractTimeSpan) {
  5657. j = n.generateMarkup(true) + j
  5658. }
  5659. })
  5660. }
  5661. this.afterPrint(l);
  5662. return {
  5663. normalHeader : k.headerCt.el.dom.innerHTML,
  5664. lockedHeader : d.headerCt.el.dom.innerHTML,
  5665. lockedGrid : !d.collapsed,
  5666. normalGrid : !k.collapsed,
  5667. lockedRows : c,
  5668. normalRows : j,
  5669. lockedScroll : g,
  5670. normalScroll : i,
  5671. lockedWidth : f,
  5672. normalWidth : a,
  5673. headerHeight : k.headerCt.getHeight(),
  5674. innerLockedClasses : d.view.el.dom.className,
  5675. innerNormalClasses : k.view.el.dom.className
  5676. + (this.fakeBackgroundColor
  5677. ? " sch-print-fake-background"
  5678. : ""),
  5679. width : l.getWidth()
  5680. }
  5681. },
  5682. getStylesheets : function() {
  5683. return Ext.getDoc().select('link[rel="stylesheet"]')
  5684. },
  5685. print : function() {
  5686. var g = this.scheduler;
  5687. if (!(this.mainTpl instanceof Ext.Template)) {
  5688. var a = 22;
  5689. this.mainTpl = Ext.create("Ext.XTemplate", this.mainTpl, {
  5690. compiled : true,
  5691. disableFormats : true
  5692. })
  5693. }
  5694. var h = g.getView(), i = this.getStylesheets(), e = Ext
  5695. .get(Ext.core.DomHelper.createDom({
  5696. tag : "div"
  5697. })), b;
  5698. i.each(function(j) {
  5699. e.appendChild(j.dom.cloneNode(true))
  5700. });
  5701. b = e.dom.innerHTML + "";
  5702. var f = this.getGridContent(g), c = this.mainTpl.apply(Ext.apply({
  5703. waitText : this.waitText,
  5704. docType : this.docType,
  5705. htmlClasses : "",
  5706. bodyClasses : Ext.getBody().dom.className,
  5707. componentClasses : g.el.dom.className,
  5708. title : (g.title || ""),
  5709. styles : b,
  5710. totalWidth : g.getWidth(),
  5711. setupScript : "(" + this.setupScript.toString() + ")();"
  5712. }, f));
  5713. var d = window.open("", "printgrid");
  5714. this.printWindow = d;
  5715. d.document.write(c);
  5716. d.document.close();
  5717. if (this.autoPrintAndClose) {
  5718. d.print();
  5719. if (!Ext.isChrome) {
  5720. d.close()
  5721. }
  5722. }
  5723. },
  5724. setupScript : function() {
  5725. var f = document.getElementById("lockedRowsCt"), d = document
  5726. .getElementById("normalRowsCt"), b = f
  5727. && f.getElementsByTagName("tr"), a = d
  5728. && d.getElementsByTagName("tr"), e = a && b ? a.length : 0, c = 0;
  5729. for (; c < e; c++) {
  5730. b[c].style.height = a[c].style.height
  5731. }
  5732. }
  5733. });
  5734. Ext.define("Sch.plugin.Export", {
  5735. extend : "Ext.util.Observable",
  5736. alternateClassName : "Sch.plugin.PdfExport",
  5737. mixins : ["Ext.AbstractPlugin"],
  5738. lockableScope : "top",
  5739. printServer : undefined,
  5740. tpl : new Ext.XTemplate(
  5741. '<!DOCTYPE html><html class="x-border-box {htmlClasses}"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /><title>{column}/{row}</title>{styles}</head><body class="x-webkit {bodyClasses}">{[this.showHeader(values)]}<div class="{componentClasses}" style="height:{bodyHeight}px; width:{totalWidth}px; position: relative !important">{HTML}</div></body></html>',
  5742. {
  5743. disableFormats : true,
  5744. showHeader : function(a) {
  5745. if (a.showHeader) {
  5746. return '<div class="sch-export-header" style="width:'
  5747. + a.totalWidth + 'px"><h2>' + a.column + "/"
  5748. + a.row + "</h2></div>"
  5749. }
  5750. return ""
  5751. }
  5752. }),
  5753. exportStatus : false,
  5754. exportDialogClassName : "Sch.widget.ExportDialog",
  5755. exportDialogConfig : {},
  5756. defaultConfig : {
  5757. format : "A4",
  5758. orientation : "portrait",
  5759. range : "complete",
  5760. showHeader : true
  5761. },
  5762. pageSizes : {
  5763. A5 : {
  5764. width : 5.8,
  5765. height : 8.3
  5766. },
  5767. A4 : {
  5768. width : 8.3,
  5769. height : 11.7
  5770. },
  5771. A3 : {
  5772. width : 11.7,
  5773. height : 16.5
  5774. },
  5775. Letter : {
  5776. width : 8.5,
  5777. height : 11
  5778. }
  5779. },
  5780. openAfterExport : true,
  5781. fileFormat : "pdf",
  5782. DPI : 72,
  5783. constructor : function(a) {
  5784. this.callParent(arguments);
  5785. this.addEvents("hidedialogwindow", "showdialogerror",
  5786. "updateprogressbar");
  5787. this.setFileFormat(this.fileFormat)
  5788. },
  5789. init : function(a) {
  5790. this.scheduler = a;
  5791. a.showExportDialog = Ext.Function.bind(this.showExportDialog, this);
  5792. a.doExport = Ext.Function.bind(this.doExport, this);
  5793. a.isExporting = Ext.Function.bind(this.isExporting, this)
  5794. },
  5795. setFileFormat : function(a) {
  5796. if (typeof a !== "string") {
  5797. this.fileFormat = "pdf"
  5798. } else {
  5799. a = a.toLowerCase();
  5800. if (a === "png") {
  5801. this.fileFormat = a
  5802. } else {
  5803. this.fileFormat = "pdf"
  5804. }
  5805. }
  5806. },
  5807. isExporting : function() {
  5808. return this.exportStatus
  5809. },
  5810. showExportDialog : function() {
  5811. var b = this, a = b.scheduler.getSchedulingView(), c;
  5812. if (b.win) {
  5813. b.win.destroy();
  5814. b.win = null
  5815. }
  5816. b.win = Ext.create(b.exportDialogClassName, {
  5817. plugin : b,
  5818. exportDialogConfig : Ext.apply({
  5819. startDate : this.scheduler.getStart(),
  5820. endDate : this.scheduler.getEnd(),
  5821. rowHeight : a.rowHeight,
  5822. columnWidth : a.getSingleTickInPixels()
  5823. }, b.exportDialogConfig)
  5824. });
  5825. b.win.show()
  5826. },
  5827. getStylesheets : function() {
  5828. var c = Ext.getDoc().select('link[rel="stylesheet"]'), a = Ext
  5829. .get(Ext.core.DomHelper.createDom({
  5830. tag : "div"
  5831. })), b;
  5832. c.each(function(d) {
  5833. a.appendChild(d.dom.cloneNode(true))
  5834. });
  5835. b = a.dom.innerHTML + "";
  5836. return b
  5837. },
  5838. doExport : function(l, i, n) {
  5839. var A = this, m = A.scheduler, o = m.getSchedulingView(), k = A
  5840. .getStylesheets(), y = l || A.defaultConfig;
  5841. A.exportStatus = true;
  5842. A.mask();
  5843. A.fireEvent("updateprogressbar", 0.1);
  5844. if (m.expandAll) {
  5845. m.expandAll()
  5846. }
  5847. var w = m.lockedGrid, p = m.normalGrid, f = o.rowHeight, z = m.timeAxis
  5848. .getTicks(), q = o.getSingleTickInPixels(), b = {
  5849. width : m.getWidth(),
  5850. height : m.getHeight(),
  5851. rowHeight : f,
  5852. columnWidth : q,
  5853. startDate : m.getStart(),
  5854. endDate : m.getEnd(),
  5855. normalWidth : p.getWidth(),
  5856. normalPosition : p.getPosition()
  5857. }, u, g;
  5858. if (y.orientation === "landscape") {
  5859. u = A.pageSizes[y.format].height * A.DPI;
  5860. g = A.pageSizes[y.format].width * A.DPI
  5861. } else {
  5862. u = A.pageSizes[y.format].width * A.DPI;
  5863. g = A.pageSizes[y.format].height * A.DPI
  5864. }
  5865. var x = 41, t = p.headerCt.getHeight(), e = Math.floor(g) - t
  5866. - (y.showHeader ? x : 0);
  5867. if (y.range !== "complete") {
  5868. var d, a, j, c, r;
  5869. if (y.range === "date") {
  5870. d = new Date(y.dateFrom);
  5871. a = new Date(y.dateTo);
  5872. if (Sch.util.Date.getDurationInDays(d, a < 1)) {
  5873. a = Sch.util.Date.add(a, Sch.util.Date.DAY, 1);
  5874. a = Sch.util.Date.constrain(a, m.getStart(), m.getEnd())
  5875. }
  5876. } else {
  5877. if (y.range === "current") {
  5878. j = o.getVisibleDateRange();
  5879. d = j.startDate;
  5880. a = j.endDate
  5881. }
  5882. }
  5883. c = Math.floor(o.timeAxis.getTickFromDate(d));
  5884. r = Math.floor(o.timeAxis.getTickFromDate(a));
  5885. z = z.filter(function(C, B) {
  5886. return B >= c && B <= r
  5887. });
  5888. m.setTimeSpan(d, a)
  5889. }
  5890. m.setWidth(u);
  5891. m.setTimeColumnWidth(q);
  5892. var h = A.calculatePages(y, z, q, u, e), v = {
  5893. ticks : z,
  5894. printHeight : e,
  5895. paperWidth : u,
  5896. headerHeight : t,
  5897. styles : k,
  5898. config : y
  5899. }, s = A.getExportJsonHtml(h, v);
  5900. A.fireEvent("updateprogressbar", 0.4);
  5901. if (A.printServer) {
  5902. Ext.Ajax.request({
  5903. type : "POST",
  5904. url : A.printServer,
  5905. params : {
  5906. html : {
  5907. array : s
  5908. },
  5909. format : y.format,
  5910. orientation : y.orientation,
  5911. range : y.range,
  5912. fileFormat : A.fileFormat
  5913. },
  5914. success : function(B) {
  5915. A.onSuccess(B, i, n)
  5916. },
  5917. failure : function(B) {
  5918. A.onFailure(B, n)
  5919. },
  5920. scope : A
  5921. })
  5922. } else {
  5923. throw "Server url not defined !"
  5924. }
  5925. A.restorePanel(b)
  5926. },
  5927. calculatePages : function(c, p, h, l, b) {
  5928. var m = this, n = m.scheduler, e = n.lockedGrid, a = n
  5929. .getSchedulingView().rowHeight, k = e.getWidth(), j = Math
  5930. .floor(l / h), g = Math.floor((l - k) / h), d = Math
  5931. .ceil((p.length - g) / j)
  5932. + 1, o = n.getSchedulingView().store.getCount(), i = Math
  5933. .floor(b / a), f = Math.ceil(o / i);
  5934. return {
  5935. columnsAmountLocked : g,
  5936. columnsAmountNormal : j,
  5937. rowsAmount : i,
  5938. rowPages : f,
  5939. columnPages : d,
  5940. timeColumnWidth : h,
  5941. lockedGridWidth : k,
  5942. rowHeight : a,
  5943. panelHTML : {}
  5944. }
  5945. },
  5946. getExportJsonHtml : function(g, B) {
  5947. var E = this, n = E.scheduler, r = g.columnsAmountLocked, t = g.columnsAmountNormal, h = g.rowsAmount, s = g.rowPages, a = g.columnPages, o = g.panelHTML, q = g.timeColumnWidth, A = B.paperWidth, d = B.printHeight, x = B.headerHeight, l = B.styles, C = B.config, D = B.ticks, w = [], j, c, m, e, b, f;
  5948. for (var z = 0; z < a; z += 1) {
  5949. if (z === 0) {
  5950. j = Ext.Number.constrain((r - 1), z, (D.length - 1));
  5951. n.setTimeSpan(D[z].start, D[j].end)
  5952. } else {
  5953. if (!c) {
  5954. c = n.lockedGrid.hide()
  5955. }
  5956. if (D[j + t]) {
  5957. n.setTimeSpan(D[j + 1].start, D[j + t].end);
  5958. j = j + t
  5959. } else {
  5960. n.setTimeSpan(D[j + 1].start, D[D.length - 1].end)
  5961. }
  5962. }
  5963. n.setTimeColumnWidth(q);
  5964. var u = new RegExp(/x-ie\d?|x-gecko/g), y = Ext.getBody().dom.className
  5965. .replace(u, ""), p = n.el.dom.className;
  5966. for (var v = 0; v < s; v += 1) {
  5967. E.hideRows(h, v);
  5968. o.dom = n.body.dom.innerHTML;
  5969. o.k = v;
  5970. o.i = z;
  5971. e = E.resizePanelHTML(o);
  5972. m = E.tpl.apply(Ext.apply({
  5973. bodyClasses : y,
  5974. bodyHeight : d + x,
  5975. componentClasses : p,
  5976. styles : l,
  5977. showHeader : C.showHeader,
  5978. HTML : e.dom.innerHTML,
  5979. totalWidth : A,
  5980. headerHeight : x,
  5981. column : z + 1,
  5982. row : v + 1
  5983. }));
  5984. f = {
  5985. html : m
  5986. };
  5987. w.push(f);
  5988. E.showRows()
  5989. }
  5990. }
  5991. this.exportStatus = false;
  5992. return Ext.JSON.encode(w)
  5993. },
  5994. resizePanelHTML : function(g) {
  5995. var h = Ext.get(Ext.core.DomHelper.createDom({
  5996. tag : "div",
  5997. html : g.dom
  5998. })), c = this.scheduler, f = c.lockedGrid, d = c.normalGrid, e, a;
  5999. if (Ext.isIE6 || Ext.isIE7 || Ext.isIEQuirks) {
  6000. var b = document.createDocumentFragment();
  6001. b.appendChild(h.dom);
  6002. e = [b.getElementById(c.id + "-targetEl"),
  6003. b.getElementById(c.id + "-innerCt"),
  6004. b.getElementById(f.id), b.getElementById(f.body.id),
  6005. b.getElementById(f.body.child(".x-grid-view").id)];
  6006. a = [b.getElementById(d.id), b.getElementById(d.headerCt.id),
  6007. b.getElementById(d.body.id),
  6008. b.getElementById(d.getView().id)];
  6009. Ext.Array.each(e, function(i) {
  6010. if (i !== null) {
  6011. i.style.height = "100%"
  6012. }
  6013. });
  6014. Ext.Array.each(a, function(j, i) {
  6015. if (j !== null) {
  6016. if (i === 1) {
  6017. j.style.width = "100%"
  6018. } else {
  6019. j.style.height = "100%";
  6020. j.style.width = "100%"
  6021. }
  6022. }
  6023. });
  6024. h.dom.innerHTML = b.firstChild.innerHTML
  6025. } else {
  6026. e = [h.select("#" + c.id + "-targetEl").first(),
  6027. h.select("#" + c.id + "-innerCt").first(),
  6028. h.select("#" + f.id).first(),
  6029. h.select("#" + f.body.id).first(),
  6030. h.select("#" + f.body.child(".x-grid-view").id).first()];
  6031. a = [h.select("#" + d.id).first(),
  6032. h.select("#" + d.headerCt.id).first(),
  6033. h.select("#" + d.body.id).first(),
  6034. h.select("#" + d.getView().id).first()];
  6035. Ext.Array.each(e, function(i) {
  6036. if (i) {
  6037. i.setHeight("100%")
  6038. }
  6039. });
  6040. Ext.Array.each(a, function(j, i) {
  6041. if (i === 1) {
  6042. j.setWidth("100%")
  6043. } else {
  6044. j.applyStyles({
  6045. height : "100%",
  6046. width : "100%"
  6047. })
  6048. }
  6049. })
  6050. }
  6051. return h
  6052. },
  6053. getWin : function() {
  6054. return this.win || null
  6055. },
  6056. onSuccess : function(c, h, b) {
  6057. var d = this, g = d.getWin(), a;
  6058. try {
  6059. a = Ext.JSON.decode(c.responseText)
  6060. } catch (f) {
  6061. this.onFailure(c, b);
  6062. return
  6063. }
  6064. d.fireEvent("updateprogressbar", 1);
  6065. if (a.success) {
  6066. setTimeout(function() {
  6067. d.fireEvent("hidedialogwindow");
  6068. d.unmask();
  6069. if (d.openAfterExport) {
  6070. window.open(a.url, "ExportedPanel")
  6071. }
  6072. }, g ? g.hideTime : 3000)
  6073. } else {
  6074. d.fireEvent("showdialogerror", g, a.msg);
  6075. d.unmask()
  6076. }
  6077. if (h) {
  6078. h.call(this, c)
  6079. }
  6080. },
  6081. onFailure : function(b, a) {
  6082. var c = this.getWin();
  6083. this.fireEvent("showdialogerror", c);
  6084. this.unmask();
  6085. if (a) {
  6086. a.call(this, b)
  6087. }
  6088. },
  6089. hideRows : function(d, f) {
  6090. var c = this.scheduler.lockedGrid.getEl().select(".x-grid-row"), a = this.scheduler.normalGrid
  6091. .getEl().select(".x-grid-row"), g = d * f, b = g + d;
  6092. for (var e = 0; e < a.elements.length; e += 1) {
  6093. if (e < g || e >= b) {
  6094. c.elements[e].className += " sch-none";
  6095. a.elements[e].className += " sch-none"
  6096. }
  6097. }
  6098. },
  6099. showRows : function() {
  6100. var b = this.scheduler.lockedGrid.getEl().select(".x-grid-row"), a = this.scheduler.normalGrid
  6101. .getEl().select(".x-grid-row");
  6102. b.each(function(c) {
  6103. c.removeCls("sch-none")
  6104. });
  6105. a.each(function(c) {
  6106. c.removeCls("sch-none")
  6107. })
  6108. },
  6109. mask : function() {
  6110. var a = Ext.getBody().mask();
  6111. a.addCls("sch-export-mask")
  6112. },
  6113. unmask : function() {
  6114. Ext.getBody().unmask()
  6115. },
  6116. restorePanel : function(a) {
  6117. var b = this.scheduler;
  6118. b.setWidth(a.width);
  6119. b.setHeight(a.height);
  6120. b.setTimeSpan(a.startDate, a.endDate);
  6121. b.setTimeColumnWidth(a.columnWidth, true);
  6122. b.getSchedulingView().setRowHeight(a.rowHeight);
  6123. b.lockedGrid.show();
  6124. b.normalGrid.setWidth(a.normalWidth);
  6125. b.normalGrid.setPosition(a.normalPosition[0])
  6126. },
  6127. destroy : function() {
  6128. if (this.win) {
  6129. this.win.destroy()
  6130. }
  6131. }
  6132. });
  6133. Ext.define("Sch.widget.ResizePicker", {
  6134. extend : "Ext.Panel",
  6135. alias : "widget.dualrangepicker",
  6136. width : 200,
  6137. height : 200,
  6138. border : true,
  6139. collapsible : false,
  6140. bodyStyle : "position:absolute; margin:5px",
  6141. verticalCfg : {
  6142. height : 120,
  6143. value : 24,
  6144. increment : 2,
  6145. minValue : 20,
  6146. maxValue : 80,
  6147. reverse : true,
  6148. disabled : true
  6149. },
  6150. horizontalCfg : {
  6151. width : 120,
  6152. value : 100,
  6153. minValue : 25,
  6154. increment : 5,
  6155. maxValue : 200,
  6156. disable : true
  6157. },
  6158. initComponent : function() {
  6159. var a = this;
  6160. a.addEvents("change", "changecomplete", "select");
  6161. a.horizontalCfg.value = a.dialogConfig.columnWidth;
  6162. a.verticalCfg.value = a.dialogConfig.rowHeight;
  6163. a.verticalCfg.disabled = a.dialogConfig.scrollerDisabled || false;
  6164. a.dockedItems = [a.vertical = new Ext.slider.Single(Ext.apply({
  6165. dock : "left",
  6166. style : "margin-top:10px",
  6167. vertical : true,
  6168. listeners : {
  6169. change : a.onSliderChange,
  6170. changecomplete : a.onSliderChangeComplete,
  6171. scope : a
  6172. }
  6173. }, a.verticalCfg)),
  6174. a.horizontal = new Ext.slider.Single(Ext.apply({
  6175. dock : "top",
  6176. style : "margin-left:28px",
  6177. listeners : {
  6178. change : a.onSliderChange,
  6179. changecomplete : a.onSliderChangeComplete,
  6180. scope : a
  6181. }
  6182. }, a.horizontalCfg))];
  6183. a.callParent(arguments)
  6184. },
  6185. afterRender : function() {
  6186. var b = this;
  6187. b.addCls("sch-ux-range-picker");
  6188. b.valueHandle = this.body.createChild({
  6189. cls : "sch-ux-range-value",
  6190. cn : {
  6191. tag : "span"
  6192. }
  6193. });
  6194. b.valueSpan = this.valueHandle.down("span");
  6195. var a = new Ext.dd.DD(this.valueHandle);
  6196. Ext.apply(a, {
  6197. startDrag : function() {
  6198. b.dragging = true;
  6199. this.constrainTo(b.body)
  6200. },
  6201. onDrag : function() {
  6202. b.onHandleDrag.apply(b, arguments)
  6203. },
  6204. endDrag : function() {
  6205. b.onHandleEndDrag.apply(b, arguments);
  6206. b.dragging = false
  6207. },
  6208. scope : this
  6209. });
  6210. this.setValues(this.getValues());
  6211. this.callParent(arguments);
  6212. this.body.on("click", this.onBodyClick, this)
  6213. },
  6214. onBodyClick : function(c, a) {
  6215. var b = [c.getXY()[0] - 8 - this.body.getX(),
  6216. c.getXY()[1] - 8 - this.body.getY()];
  6217. this.valueHandle.setLeft(Ext.Number.constrain(b[0], 0, this
  6218. .getAvailableWidth()));
  6219. this.valueHandle.setTop(Ext.Number.constrain(b[1], 0, this
  6220. .getAvailableHeight()));
  6221. this.setValues(this.getValuesFromXY([this.valueHandle.getLeft(true),
  6222. this.valueHandle.getTop(true)]));
  6223. this.onSliderChangeComplete()
  6224. },
  6225. getAvailableWidth : function() {
  6226. return this.body.getWidth() - 18
  6227. },
  6228. getAvailableHeight : function() {
  6229. return this.body.getHeight() - 18
  6230. },
  6231. onHandleDrag : function() {
  6232. this.setValues(this.getValuesFromXY([this.valueHandle.getLeft(true),
  6233. this.valueHandle.getTop(true)]))
  6234. },
  6235. onHandleEndDrag : function() {
  6236. this.setValues(this.getValuesFromXY([this.valueHandle.getLeft(true),
  6237. this.valueHandle.getTop(true)]))
  6238. },
  6239. getValuesFromXY : function(d) {
  6240. var c = d[0] / this.getAvailableWidth();
  6241. var a = d[1] / this.getAvailableHeight();
  6242. var e = Math
  6243. .round((this.horizontalCfg.maxValue - this.horizontalCfg.minValue)
  6244. * c);
  6245. var b = Math
  6246. .round((this.verticalCfg.maxValue - this.verticalCfg.minValue)
  6247. * a)
  6248. + this.verticalCfg.minValue;
  6249. return [e + this.horizontalCfg.minValue, b]
  6250. },
  6251. getXYFromValues : function(d) {
  6252. var b = this.horizontalCfg.maxValue - this.horizontalCfg.minValue;
  6253. var f = this.verticalCfg.maxValue - this.verticalCfg.minValue;
  6254. var a = Math.round((d[0] - this.horizontalCfg.minValue)
  6255. * this.getAvailableWidth() / b);
  6256. var c = d[1] - this.verticalCfg.minValue;
  6257. var e = Math.round(c * this.getAvailableHeight() / f);
  6258. return [a, e]
  6259. },
  6260. updatePosition : function() {
  6261. var a = this.getValues();
  6262. var b = this.getXYFromValues(a);
  6263. this.valueHandle.setLeft(Ext.Number.constrain(b[0], 0, this
  6264. .getAvailableWidth()));
  6265. if (this.verticalCfg.disabled) {
  6266. this.valueHandle.setTop(this.dialogConfig.rowHeight)
  6267. } else {
  6268. this.valueHandle.setTop(Ext.Number.constrain(b[1], 0, this
  6269. .getAvailableHeight()))
  6270. }
  6271. this.positionValueText();
  6272. this.setValueText(a)
  6273. },
  6274. positionValueText : function() {
  6275. var a = this.valueHandle.getTop(true);
  6276. var b = this.valueHandle.getLeft(true);
  6277. this.valueSpan.setLeft(b > 30 ? -30 : 10);
  6278. this.valueSpan.setTop(a > 10 ? -20 : 20)
  6279. },
  6280. setValueText : function(a) {
  6281. if (this.verticalCfg.disabled) {
  6282. a[1] = this.dialogConfig.rowHeight
  6283. }
  6284. this.valueSpan.update("[" + a.toString() + "]")
  6285. },
  6286. setValues : function(a) {
  6287. this.horizontal.setValue(a[0]);
  6288. if (this.verticalCfg.reverse) {
  6289. if (!this.verticalCfg.disabled) {
  6290. this.vertical.setValue(this.verticalCfg.maxValue
  6291. + this.verticalCfg.minValue - a[1])
  6292. }
  6293. } else {
  6294. if (!this.verticalCfg.disabled) {
  6295. this.vertical.setValue(a[1])
  6296. }
  6297. }
  6298. if (!this.dragging) {
  6299. this.updatePosition()
  6300. }
  6301. this.positionValueText();
  6302. this.setValueText(a)
  6303. },
  6304. getValues : function() {
  6305. var a = this.vertical.getValue();
  6306. if (this.verticalCfg.reverse) {
  6307. a = this.verticalCfg.maxValue - a + this.verticalCfg.minValue
  6308. }
  6309. return [this.horizontal.getValue(), a]
  6310. },
  6311. onSliderChange : function() {
  6312. this.fireEvent("change", this, this.getValues());
  6313. if (!this.dragging) {
  6314. this.updatePosition()
  6315. }
  6316. },
  6317. onSliderChangeComplete : function() {
  6318. this.fireEvent("changecomplete", this, this.getValues())
  6319. },
  6320. afterLayout : function() {
  6321. this.callParent(arguments);
  6322. this.updatePosition()
  6323. }
  6324. });
  6325. Ext.define("Sch.widget.ExportDialogForm", {
  6326. extend : "Ext.form.Panel",
  6327. requires : ["Ext.ProgressBar", "Sch.widget.ResizePicker"],
  6328. border : false,
  6329. bodyPadding : "10 10 0 10",
  6330. autoHeight : true,
  6331. initComponent : function() {
  6332. var a = this;
  6333. a.createFields();
  6334. Ext.apply(this, {
  6335. fieldDefaults : {
  6336. labelAlign : "top",
  6337. labelWidth : 100,
  6338. anchor : "90%"
  6339. },
  6340. items : [a.rangeField, a.resizePicker, a.dateFromField,
  6341. a.dateToField, a.showHeaderField, a.formatField,
  6342. a.orientationField,
  6343. a.progressBar || a.createProgressBar()]
  6344. });
  6345. a.callParent(arguments);
  6346. a.on({
  6347. hideprogressbar : a.hideProgressBar,
  6348. showprogressbar : a.showProgressBar,
  6349. updateprogressbar : a.updateProgressBar,
  6350. scope : a
  6351. })
  6352. },
  6353. createFields : function() {
  6354. var b = this, a = b.dialogConfig;
  6355. b.rangeField = new Ext.form.field.ComboBox({
  6356. xtype : "combo",
  6357. value : "complete",
  6358. triggerAction : "all",
  6359. cls : "sch-export-dialog-range",
  6360. forceSelection : true,
  6361. editable : false,
  6362. fieldLabel : a.rangeFieldLabel,
  6363. name : "range",
  6364. queryMode : "local",
  6365. displayField : "name",
  6366. valueField : "value",
  6367. store : Ext.create("Ext.data.Store", {
  6368. fields : ["name", "value"],
  6369. data : [{
  6370. name : a.completeView,
  6371. value : "complete"
  6372. }, {
  6373. name : a.dateRange,
  6374. value : "date"
  6375. }, {
  6376. name : a.currentView,
  6377. value : "current"
  6378. }]
  6379. }),
  6380. listeners : {
  6381. change : b.onRangeChange,
  6382. scope : b
  6383. }
  6384. });
  6385. b.resizePicker = new Sch.widget.ResizePicker({
  6386. dialogConfig : a,
  6387. hidden : true,
  6388. padding : "0 0 5 0"
  6389. });
  6390. b.dateFromField = new Ext.form.field.Date({
  6391. fieldLabel : a.dateRangeFrom,
  6392. labelAlign : "left",
  6393. labelWidth : 80,
  6394. baseBodyCls : "sch-exportdialogform-date",
  6395. padding : "10 0 5 0",
  6396. name : "dateFrom",
  6397. format : a.dateRangeFormat || Ext.Date.defaultFormat,
  6398. hidden : true,
  6399. allowBlank : false,
  6400. maxValue : a.endDate,
  6401. minValue : a.startDate,
  6402. value : a.startDate,
  6403. validator : function(c) {
  6404. return Ext.Date.parse(c, this.format) >= new Date(a.startDate)
  6405. }
  6406. });
  6407. b.dateToField = new Ext.form.field.Date({
  6408. fieldLabel : a.dateRangeTo,
  6409. labelAlign : "left",
  6410. labelWidth : 80,
  6411. name : "dateTo",
  6412. format : a.dateRangeFormat || Ext.Date.defaultFormat,
  6413. baseBodyCls : "sch-exportdialogform-date",
  6414. hidden : true,
  6415. allowBlank : false,
  6416. maxValue : a.endDate,
  6417. minValue : a.startDate,
  6418. value : a.endDate,
  6419. validator : function(c) {
  6420. return Ext.Date.parse(c, this.format) <= new Date(a.endDate)
  6421. }
  6422. });
  6423. b.showHeaderField = new Ext.form.field.Checkbox({
  6424. xtype : "checkboxfield",
  6425. fieldLabel : b.dialogConfig.showHeaderLabel,
  6426. name : "showHeader",
  6427. checked : true
  6428. });
  6429. b.formatField = new Ext.form.field.ComboBox({
  6430. value : "A4",
  6431. triggerAction : "all",
  6432. forceSelection : true,
  6433. editable : false,
  6434. fieldLabel : a.formatFieldLabel,
  6435. name : "format",
  6436. queryMode : "local",
  6437. store : ["A5", "A4", "A3", "Letter"]
  6438. });
  6439. b.orientationField = new Ext.form.field.ComboBox({
  6440. value : "portrait",
  6441. triggerAction : "all",
  6442. baseBodyCls : "sch-exportdialogform-orientation",
  6443. forceSelection : true,
  6444. editable : false,
  6445. fieldLabel : b.dialogConfig.orientationFieldLabel,
  6446. afterSubTpl : new Ext.XTemplate('<span id="sch-exportdialog-imagePortrait"></span><span id="sch-exportdialog-imageLandscape" class="sch-none"></span>'),
  6447. name : "orientation",
  6448. displayField : "name",
  6449. valueField : "value",
  6450. queryMode : "local",
  6451. store : Ext.create("Ext.data.Store", {
  6452. fields : ["name", "value"],
  6453. data : [{
  6454. name : a.orientationPortrait,
  6455. value : "portrait"
  6456. }, {
  6457. name : a.orientationLandscape,
  6458. value : "landscape"
  6459. }]
  6460. }),
  6461. listeners : {
  6462. change : function(d, c) {
  6463. switch (c) {
  6464. case "landscape" :
  6465. Ext.fly("sch-exportdialog-imagePortrait")
  6466. .toggleCls("sch-none");
  6467. Ext.fly("sch-exportdialog-imageLandscape")
  6468. .toggleCls("sch-none");
  6469. break;
  6470. case "portrait" :
  6471. Ext.fly("sch-exportdialog-imagePortrait")
  6472. .toggleCls("sch-none");
  6473. Ext.fly("sch-exportdialog-imageLandscape")
  6474. .toggleCls("sch-none");
  6475. break
  6476. }
  6477. }
  6478. }
  6479. })
  6480. },
  6481. createProgressBar : function() {
  6482. return this.progressBar = new Ext.ProgressBar({
  6483. text : this.config.progressBarText,
  6484. animate : true,
  6485. hidden : true,
  6486. id : "print-widget-progressbar"
  6487. })
  6488. },
  6489. onRangeChange : function(b, a) {
  6490. switch (a) {
  6491. case "complete" :
  6492. this.dateFromField.hide();
  6493. this.dateToField.hide();
  6494. this.resizePicker.hide();
  6495. break;
  6496. case "date" :
  6497. this.dateFromField.show();
  6498. this.dateToField.show();
  6499. this.resizePicker.hide();
  6500. break;
  6501. case "current" :
  6502. this.dateFromField.hide();
  6503. this.dateToField.hide();
  6504. this.resizePicker.show();
  6505. this.resizePicker.expand(true);
  6506. break
  6507. }
  6508. },
  6509. showProgressBar : function() {
  6510. if (this.progressBar) {
  6511. this.progressBar.show()
  6512. }
  6513. },
  6514. hideProgressBar : function() {
  6515. if (this.progressBar) {
  6516. this.progressBar.hide()
  6517. }
  6518. },
  6519. updateProgressBar : function(a) {
  6520. if (this.progressBar) {
  6521. this.progressBar.updateProgress(a)
  6522. }
  6523. }
  6524. });
  6525. Ext.define("Sch.widget.ExportDialog", {
  6526. alternateClassName : "Sch.widget.PdfExportDialog",
  6527. extend : "Ext.window.Window",
  6528. alias : "widget.exportdialog",
  6529. modal : false,
  6530. width : 240,
  6531. cls : "sch-exportdialog",
  6532. frame : false,
  6533. layout : "card",
  6534. draggable : false,
  6535. padding : 0,
  6536. plugin : null,
  6537. hideTime : 2000,
  6538. buttonsPanel : null,
  6539. buttonsPanelScope : null,
  6540. progressBar : null,
  6541. generalError : "An error occured, try again.",
  6542. title : "Export Settings",
  6543. formatFieldLabel : "Paper format",
  6544. orientationFieldLabel : "Orientation",
  6545. rangeFieldLabel : "Export range",
  6546. showHeaderLabel : "Add page number",
  6547. orientationPortrait : "Portrait",
  6548. orientationLandscape : "Landscape",
  6549. completeView : "Complete schedule",
  6550. currentView : "Current view",
  6551. dateRange : "Date range",
  6552. dateRangeFrom : "Export from",
  6553. pickerText : "Resize column/rows to desired value",
  6554. dateRangeTo : "Export to",
  6555. exportButtonText : "Export",
  6556. cancelButtonText : "Cancel",
  6557. progressBarText : "Exporting...",
  6558. dateRangeFormat : "",
  6559. requires : ["Sch.widget.ExportDialogForm"],
  6560. constructor : function(a) {
  6561. Ext.apply(this, a.exportDialogConfig);
  6562. this.config = Ext.apply({
  6563. progressBarText : this.progressBarText,
  6564. cancelButtonText : this.cancelButtonText,
  6565. exportButtonText : this.exportButtonText,
  6566. dateRangeTo : this.dateRangeTo,
  6567. pickerText : this.pickerText,
  6568. dateRangeFrom : this.dateRangeFrom,
  6569. dateRange : this.dateRange,
  6570. currentView : this.currentView,
  6571. formatFieldLabel : this.formatFieldLabel,
  6572. orientationFieldLabel : this.orientationFieldLabel,
  6573. rangeFieldLabel : this.rangeFieldLabel,
  6574. showHeaderLabel : this.showHeaderLabel,
  6575. orientationPortrait : this.orientationPortrait,
  6576. orientationLandscape : this.orientationLandscape,
  6577. completeView : this.completeView,
  6578. dateRangeFormat : this.dateRangeFormat
  6579. }, a.exportDialogConfig);
  6580. this.callParent(arguments)
  6581. },
  6582. initComponent : function() {
  6583. var b = this, a = {
  6584. hidedialogwindow : b.destroy,
  6585. showdialogerror : b.showError,
  6586. updateprogressbar : function(c) {
  6587. b.fireEvent("updateprogressbar", c)
  6588. },
  6589. scope : this
  6590. };
  6591. Ext.apply(this, {
  6592. items : [b.form = b.buildForm(b.config),
  6593. b.createMessageElement()],
  6594. fbar : b.buildButtons(b.buttonsPanelScope || b)
  6595. });
  6596. b.callParent(arguments);
  6597. b.plugin.on(a)
  6598. },
  6599. afterRender : function() {
  6600. var a = this;
  6601. a.on("changecomplete", function(c, b) {
  6602. a.plugin.scheduler.setTimeColumnWidth(b[0], true);
  6603. if (!a.config.scrollerDisabled) {
  6604. if (a.form.resizePicker.verticalCfg.reverse) {
  6605. var d = b[1];
  6606. a.plugin.scheduler.getSchedulingView()
  6607. .setRowHeight(d)
  6608. } else {
  6609. a.plugin.scheduler.getSchedulingView()
  6610. .setRowHeight(b[1])
  6611. }
  6612. }
  6613. });
  6614. a.relayEvents(a.form.resizePicker, ["change", "changecomplete",
  6615. "select"]);
  6616. a.form.relayEvents(a, ["updateprogressbar", "hideprogressbar",
  6617. "showprogressbar"]);
  6618. a.callParent(arguments);
  6619. a.switchTab(0)
  6620. },
  6621. createMessageElement : function() {
  6622. var a = this;
  6623. return a.messageElement = new Ext.Component({
  6624. autoEl : {
  6625. tag : "div",
  6626. cls : "sch-exportdialog-msg"
  6627. }
  6628. })
  6629. },
  6630. buildButtons : function(a) {
  6631. return [{
  6632. xtype : "button",
  6633. scale : "medium",
  6634. text : this.exportButtonText,
  6635. handler : function() {
  6636. var c = this.form.getForm();
  6637. if (c.isValid()) {
  6638. var b = c.getValues();
  6639. this.fireEvent("showprogressbar");
  6640. this.plugin.doExport(b)
  6641. }
  6642. },
  6643. scope : a
  6644. }, {
  6645. xtype : "button",
  6646. scale : "medium",
  6647. text : this.cancelButtonText,
  6648. handler : function() {
  6649. this.destroy()
  6650. },
  6651. scope : a
  6652. }]
  6653. },
  6654. buildForm : function(a) {
  6655. return new Sch.widget.ExportDialogForm({
  6656. progressBar : this.progressBar,
  6657. dialogConfig : a
  6658. })
  6659. },
  6660. switchTab : function(a) {
  6661. this.getLayout().setActiveItem(a)
  6662. },
  6663. showError : function(b, a) {
  6664. var c = b, d = a || c.generalError;
  6665. c.fireEvent("hideprogressbar");
  6666. c.switchTab(1);
  6667. c.messageElement.getEl().setHTML(d);
  6668. setTimeout(function() {
  6669. c.hide()
  6670. }, c.hideTime)
  6671. }
  6672. });
  6673. Ext.define("Gnt.model.WeekAvailability", {
  6674. extend : "Sch.model.Range",
  6675. customizableFields : [{
  6676. name : "Availability"
  6677. }],
  6678. availabilityField : "Availability",
  6679. set : function(b, a) {
  6680. if (b === this.nameField) {
  6681. Ext.Array.each(this.getAvailability(), function(c) {
  6682. c.setName(a)
  6683. })
  6684. }
  6685. this.callParent(arguments)
  6686. },
  6687. getAvailability : function() {
  6688. return this.get(this.availabilityField) || []
  6689. },
  6690. setAvailability : function(b) {
  6691. var a = this.getName();
  6692. Ext.Array.each(b, function(c) {
  6693. c.setName(a)
  6694. });
  6695. this.set(this.availabilityField, b)
  6696. }
  6697. });
  6698. Ext.define("Gnt.model.CalendarDay", {
  6699. requires : ["Ext.data.Types"],
  6700. extend : "Sch.model.Customizable",
  6701. idProperty : "Id",
  6702. customizableFields : [{
  6703. name : "Date",
  6704. type : "date",
  6705. dateFormat : "c",
  6706. convert : function(b, a) {
  6707. if (!b) {
  6708. return
  6709. }
  6710. var c = Ext.data.Types.DATE.convert.call(this, b);
  6711. if (c) {
  6712. Ext.Date.clearTime(c)
  6713. }
  6714. if (a.data[a.idProperty] == null) {
  6715. a.data[a.idProperty] = c - 0
  6716. }
  6717. return c
  6718. }
  6719. }, {
  6720. name : "Id"
  6721. }, {
  6722. name : "IsWorkingDay",
  6723. type : "boolean",
  6724. defaultValue : false
  6725. }, {
  6726. name : "Cls",
  6727. defaultValue : "gnt-holiday"
  6728. }, "Name", {
  6729. name : "Availability",
  6730. convert : function(b, a) {
  6731. if (b) {
  6732. return Ext.typeOf(b) === "string" ? [b] : b
  6733. } else {
  6734. return []
  6735. }
  6736. }
  6737. }],
  6738. availabilityCache : null,
  6739. dateField : "Date",
  6740. isWorkingDayField : "IsWorkingDay",
  6741. clsField : "Cls",
  6742. nameField : "Name",
  6743. availabilityField : "Availability",
  6744. setDate : function(b) {
  6745. var a = Ext.Date.clearTime(b, true);
  6746. this.data[this.idProperty] = a - 0;
  6747. this.set(this.dateField, a)
  6748. },
  6749. clearDate : function() {
  6750. this.data[this.idProperty] = null
  6751. },
  6752. getAvailability : function(b) {
  6753. var c = this;
  6754. if (b) {
  6755. return this.get(this.availabilityField)
  6756. }
  6757. if (this.availabilityCache) {
  6758. return this.availabilityCache
  6759. }
  6760. var a = [];
  6761. Ext.Array.each(this.get(this.availabilityField), function(d) {
  6762. a.push(Ext.typeOf(d) === "string" ? c
  6763. .parseInterval(d) : d)
  6764. });
  6765. this.verifyAvailability(a);
  6766. return this.availabilityCache = a
  6767. },
  6768. setAvailability : function(a) {
  6769. this.availabilityCache = null;
  6770. this.set(this.availabilityField, this.stringifyIntervals(a));
  6771. this.getAvailability()
  6772. },
  6773. verifyAvailability : function(b) {
  6774. b.sort(function(f, e) {
  6775. return f.startTime - e.startTime
  6776. });
  6777. Ext.Array.each(b, function(e) {
  6778. if (e.startTime > e.endTime) {
  6779. throw "Start time is greater than end time"
  6780. }
  6781. });
  6782. for (var a = 1; a < b.length; a++) {
  6783. var c = b[a - 1];
  6784. var d = b[a];
  6785. if (c.endTime > d.startTime) {
  6786. throw "Availability intervals should not intersect"
  6787. }
  6788. }
  6789. },
  6790. prependZero : function(a) {
  6791. return a < 10 ? "0" + a : a
  6792. },
  6793. stringifyInterval : function(b) {
  6794. var c = b.startTime;
  6795. var a = b.endTime;
  6796. return this.prependZero(c.getHours()) + ":"
  6797. + this.prependZero(c.getMinutes()) + "-"
  6798. + this.prependZero(a.getHours()) + ":"
  6799. + this.prependZero(a.getMinutes())
  6800. },
  6801. stringifyIntervals : function(b) {
  6802. var c = this;
  6803. var a = [];
  6804. Ext.Array.each(b, function(d) {
  6805. if (Ext.typeOf(d) === "string") {
  6806. a.push(d)
  6807. } else {
  6808. a.push(c.stringifyInterval(d))
  6809. }
  6810. });
  6811. return a
  6812. },
  6813. parseInterval : function(b) {
  6814. var a = /(\d\d):(\d\d)-(\d\d):(\d\d)/.exec(b);
  6815. if (!a) {
  6816. throw "Invalid format for availability string: " + b
  6817. + ". It should have exact format: hh:mm-hh:mm"
  6818. }
  6819. return {
  6820. startTime : new Date(0, 0, 0, a[1], a[2]),
  6821. endTime : new Date(0, 0, 0, a[3], a[4])
  6822. }
  6823. },
  6824. getTotalHours : function() {
  6825. return this.getTotalMS() / 1000 / 60 / 60
  6826. },
  6827. getTotalMS : function() {
  6828. var a = 0;
  6829. Ext.Array.each(this.getAvailability(), function(b) {
  6830. a += b.endTime - b.startTime
  6831. });
  6832. return a
  6833. },
  6834. addAvailabilityInterval : function(d, b) {
  6835. var a;
  6836. if (d instanceof Date) {
  6837. a = {
  6838. startTime : d,
  6839. endTime : b
  6840. }
  6841. } else {
  6842. a = this.parseInterval(d + (b ? "-" + b : ""))
  6843. }
  6844. var c = this.getAvailability().concat(a);
  6845. this.verifyAvailability(c);
  6846. this.setAvailability(c)
  6847. },
  6848. removeAvailbilityInterval : function(a) {
  6849. var b = this.getAvailability();
  6850. b.splice(a, 1);
  6851. this.setAvailability(b)
  6852. },
  6853. getAvailabilityIntervalsFor : function(d) {
  6854. d = typeof d == "number" ? new Date(d) : d;
  6855. var c = d.getFullYear();
  6856. var e = d.getMonth();
  6857. var b = d.getDate();
  6858. var a = [];
  6859. Ext.Array.each(this.getAvailability(), function(f) {
  6860. var g = f.endTime.getDate();
  6861. a.push({
  6862. startDate : new Date(c, e, b,
  6863. f.startTime.getHours(),
  6864. f.startTime.getMinutes()),
  6865. endDate : new Date(c, e, b
  6866. + (g == 1 ? 1 : 0),
  6867. f.endTime.getHours(), f.endTime
  6868. .getMinutes())
  6869. })
  6870. });
  6871. return a
  6872. },
  6873. getAvailabilityStartFor : function(b) {
  6874. var a = this.getAvailabilityIntervalsFor(b);
  6875. if (!a.length) {
  6876. return null
  6877. }
  6878. return a[0].startDate
  6879. },
  6880. getAvailabilityEndFor : function(b) {
  6881. var a = this.getAvailabilityIntervalsFor(b);
  6882. if (!a.length) {
  6883. return null
  6884. }
  6885. return a[a.length - 1].endDate
  6886. }
  6887. });
  6888. Ext.define("Gnt.model.Assignment", {
  6889. extend : "Sch.model.Customizable",
  6890. idProperty : "Id",
  6891. customizableFields : [{
  6892. name : "Id"
  6893. }, {
  6894. name : "ResourceId"
  6895. }, {
  6896. name : "TaskId"
  6897. }, {
  6898. name : "Units",
  6899. type : "float",
  6900. defaultValue : 100
  6901. }],
  6902. resourceIdField : "ResourceId",
  6903. taskIdField : "TaskId",
  6904. unitsField : "Units",
  6905. isPersistable : function() {
  6906. var a = this.getTask(), b = this.getResource();
  6907. return a && !a.phantom && b && !b.phantom
  6908. },
  6909. getUnits : function() {
  6910. return Math.max(0, this.get(this.unitsField))
  6911. },
  6912. setUnits : function(a) {
  6913. if (a < 0) {
  6914. throw "`Units` value for an assignment can't be less than 0"
  6915. }
  6916. this.set(this.unitsField, a)
  6917. },
  6918. getResourceName : function() {
  6919. var a = this.stores[0].getResourceStore().getById(this.getResourceId());
  6920. if (a) {
  6921. return a.getName()
  6922. }
  6923. return ""
  6924. },
  6925. getTask : function(a) {
  6926. return (a || this.stores[0].getTaskStore()).getById(this.getTaskId())
  6927. },
  6928. getResource : function() {
  6929. return this.stores[0].getResourceStore().getByInternalId(this
  6930. .getResourceId())
  6931. },
  6932. getInternalId : function() {
  6933. return this.getId() || this.internalId
  6934. },
  6935. getEffort : function(b) {
  6936. var a = this.getTask();
  6937. var c = 0;
  6938. a.forEachAvailabilityIntervalWithResources({
  6939. startDate : a.getStartDate(),
  6940. endDate : a.getEndDate(),
  6941. resources : [this.getResource()]
  6942. }, function(g, f, e) {
  6943. var h;
  6944. for (var d in e) {
  6945. h = e[d].units
  6946. }
  6947. c += (f - g) * h / 100
  6948. });
  6949. return a.getProjectCalendar().convertMSDurationToUnit(c,
  6950. b || a.getEffortUnit())
  6951. }
  6952. });
  6953. Ext.define("Gnt.model.Dependency", {
  6954. extend : "Sch.model.Customizable",
  6955. inheritableStatics : {
  6956. Type : {
  6957. StartToStart : 0,
  6958. StartToEnd : 1,
  6959. EndToStart : 2,
  6960. EndToEnd : 3
  6961. }
  6962. },
  6963. idProperty : "Id",
  6964. customizableFields : [{
  6965. name : "Id"
  6966. }, {
  6967. name : "From"
  6968. }, {
  6969. name : "To"
  6970. }, {
  6971. name : "Type",
  6972. type : "int",
  6973. defaultValue : 2
  6974. }, {
  6975. name : "Lag",
  6976. type : "number",
  6977. defaultValue : 0
  6978. }, {
  6979. name : "LagUnit",
  6980. type : "string",
  6981. defaultValue : "d",
  6982. convert : function(a) {
  6983. return a || "d"
  6984. }
  6985. }, {
  6986. name : "Cls"
  6987. }],
  6988. fromField : "From",
  6989. toField : "To",
  6990. typeField : "Type",
  6991. lagField : "Lag",
  6992. lagUnitField : "LagUnit",
  6993. clsField : "Cls",
  6994. fromTask : null,
  6995. toTask : null,
  6996. constructor : function(a) {
  6997. this.callParent(arguments);
  6998. if (a) {
  6999. if (a.fromTask) {
  7000. if (a.fromTask instanceof Gnt.model.Task) {
  7001. this.setSourceTask(a.fromTask)
  7002. } else {
  7003. this.setSourceId(a.fromTask)
  7004. }
  7005. }
  7006. if (a.toTask) {
  7007. if (a.toTask instanceof Gnt.model.Task) {
  7008. this.setTargetTask(a.toTask)
  7009. } else {
  7010. this.setTargetId(a.toTask)
  7011. }
  7012. }
  7013. if (Ext.isDefined(a.type)) {
  7014. this.setType(a.type)
  7015. }
  7016. if (Ext.isDefined(a.lag)) {
  7017. this.setLag(a.lag)
  7018. }
  7019. if (Ext.isDefined(a.lagUnit)) {
  7020. this.setLagUnit(a.lagUnit)
  7021. }
  7022. }
  7023. },
  7024. getTaskStore : function() {
  7025. return this.stores[0].taskStore
  7026. },
  7027. getSourceTask : function(a) {
  7028. return (a || this.getTaskStore()).getById(this.getSourceId())
  7029. },
  7030. setSourceTask : function(a) {
  7031. this.setSourceId(a.getId() || a.internalId)
  7032. },
  7033. getTargetTask : function(a) {
  7034. return (a || this.getTaskStore()).getById(this.getTargetId())
  7035. },
  7036. setTargetTask : function(a) {
  7037. this.setTargetId(a.getId() || a.internalId)
  7038. },
  7039. getSourceId : function() {
  7040. return this.get(this.fromField)
  7041. },
  7042. setSourceId : function(a) {
  7043. this.set(this.fromField, a)
  7044. },
  7045. getTargetId : function() {
  7046. return this.get(this.toField)
  7047. },
  7048. setTargetId : function(a) {
  7049. this.set(this.toField, a)
  7050. },
  7051. getLagUnit : function() {
  7052. return this.get(this.lagUnitField) || "d"
  7053. },
  7054. isPersistable : function() {
  7055. var a = this.getSourceTask(), b = this.getTargetTask();
  7056. return a && !a.phantom && b && !b.phantom
  7057. },
  7058. isValid : function(b) {
  7059. var c = this.callParent(arguments), d = this.getSourceId(), a = this
  7060. .getTargetId();
  7061. if (c) {
  7062. c = Ext.isNumber(this.getType()) && !Ext.isEmpty(d)
  7063. && !Ext.isEmpty(a)
  7064. }
  7065. if (c && b !== false && this.stores[0]) {
  7066. c = this.stores[0].isValidDependency(d, a, true)
  7067. }
  7068. return c
  7069. }
  7070. });
  7071. Ext.define("Gnt.model.Resource", {
  7072. extend : "Sch.model.Resource",
  7073. customizableFields : ["CalendarId"],
  7074. calendarIdField : "CalendarId",
  7075. getTaskStore : function() {
  7076. return this.stores[0].getTaskStore()
  7077. },
  7078. getEventStore : function() {
  7079. return this.getTaskStore()
  7080. },
  7081. getEvents : function() {
  7082. return this.getTasks()
  7083. },
  7084. getTasks : function() {
  7085. var a = [];
  7086. this.forEachAssignment(function(b) {
  7087. var c = b.getTask();
  7088. if (c) {
  7089. a.push(c)
  7090. }
  7091. });
  7092. return a
  7093. },
  7094. getCalendar : function(a) {
  7095. return a ? this.getOwnCalendar() : this.getOwnCalendar()
  7096. || this.getProjectCalendar()
  7097. },
  7098. getOwnCalendar : function() {
  7099. var a = this.getCalendarId();
  7100. return a ? Gnt.data.Calendar.getCalendar(a) : null
  7101. },
  7102. getProjectCalendar : function() {
  7103. return this.stores[0].getTaskStore().getCalendar()
  7104. },
  7105. setCalendar : function(a) {
  7106. },
  7107. getInternalId : function() {
  7108. return this.getId() || this.internalId
  7109. },
  7110. assignTo : function(a, c) {
  7111. var b = a instanceof Gnt.model.Task ? a : this.getTaskStore()
  7112. .getById(a);
  7113. return b.assign(this, c)
  7114. },
  7115. unassignFrom : function() {
  7116. return this.unAssignFrom.apply(this, arguments)
  7117. },
  7118. unAssignFrom : function(a) {
  7119. var b = a instanceof Gnt.model.Task ? a : this.getTaskStore()
  7120. .getById(a);
  7121. b.unAssign(this)
  7122. },
  7123. forEachAssignment : function(b, a) {
  7124. a = a || this;
  7125. var c = this.getInternalId();
  7126. this.getTaskStore().getAssignmentStore().each(function(d) {
  7127. if (d.getResourceId() == c) {
  7128. return b.call(a, d)
  7129. }
  7130. })
  7131. },
  7132. collectAvailabilityIntervalPoints : function(e, f, b, h, c) {
  7133. for (var d = 0; d < e.length; d++) {
  7134. var a = e[d];
  7135. var g = a.startDate - 0;
  7136. var i = a.endDate - 0;
  7137. if (!h[g]) {
  7138. h[g] = [];
  7139. c.push(g)
  7140. }
  7141. h[g].push(f(g));
  7142. if (!h[i]) {
  7143. h[i] = [];
  7144. c.push(i)
  7145. }
  7146. h[i].push(b(i))
  7147. }
  7148. },
  7149. forEachAvailabilityIntervalWithTasks : function(d, f, a) {
  7150. a = a || this;
  7151. var c = d.startDate;
  7152. var t = d.endDate;
  7153. if (!c || !t) {
  7154. throw "Both `startDate` and `endDate` are required for `forEachAvailabilityIntervalWithTasks`"
  7155. }
  7156. var g = new Date(c);
  7157. var u = d.includeAllIntervals;
  7158. var p = this.getCalendar();
  7159. var l = [];
  7160. var n = [];
  7161. var b = [];
  7162. this.forEachAssignment(function(k) {
  7163. var i = k.getTask();
  7164. if (i.getStartDate() > t || i.getEndDate() < c) {
  7165. return
  7166. }
  7167. n.push(i);
  7168. b.push(i.getCalendar());
  7169. l.push(k)
  7170. });
  7171. if (!n.length) {
  7172. return
  7173. }
  7174. var e = Sch.util.Date;
  7175. var y = [c - 0, t - 0];
  7176. var j = {};
  7177. j[c - 0] = [{
  7178. type : "00-intervalStart"
  7179. }];
  7180. j[t - 0] = [{
  7181. type : "00-intervalEnd"
  7182. }];
  7183. var s;
  7184. while (g < t) {
  7185. this.collectAvailabilityIntervalPoints(p
  7186. .getAvailabilityIntervalsFor(g), function() {
  7187. return {
  7188. type : "00-resourceAvailabilityStart"
  7189. }
  7190. }, function() {
  7191. return {
  7192. type : "01-resourceAvailabilityEnd"
  7193. }
  7194. }, j, y);
  7195. for (s = 0; s < b.length; s++) {
  7196. this.collectAvailabilityIntervalPoints(b[s]
  7197. .getAvailabilityIntervalsFor(g), function() {
  7198. return {
  7199. type : "02-taskAvailabilityStart",
  7200. assignment : l[s],
  7201. taskId : n[s].getInternalId(),
  7202. units : l[s].getUnits()
  7203. }
  7204. }, function() {
  7205. return {
  7206. type : "03-taskAvailabilityEnd",
  7207. taskId : n[s].getInternalId()
  7208. }
  7209. }, j, y)
  7210. }
  7211. g = e.getStartOfNextDay(g)
  7212. }
  7213. y.sort();
  7214. var v = false;
  7215. var w = {};
  7216. var m = 0;
  7217. for (s = 0; s < y.length - 1; s++) {
  7218. var r = j[y[s]];
  7219. r.sort(function(k, i) {
  7220. return k.type < i.type
  7221. });
  7222. for (var q = 0; q < r.length; q++) {
  7223. var o = r[q];
  7224. if (o.type == "00-resourceAvailabilityStart") {
  7225. v = true
  7226. }
  7227. if (o.type == "01-resourceAvailabilityEnd") {
  7228. v = false
  7229. }
  7230. if (o.type == "02-taskAvailabilityStart") {
  7231. w[o.taskId] = o;
  7232. m++
  7233. }
  7234. if (o.type == "03-taskAvailabilityEnd") {
  7235. delete w[o.taskId];
  7236. m--
  7237. }
  7238. }
  7239. if (u || v && m) {
  7240. var x = y[s];
  7241. var h = y[s + 1];
  7242. if (x > t || h < c) {
  7243. continue
  7244. }
  7245. if (x < c) {
  7246. x = c - 0
  7247. }
  7248. if (h > t) {
  7249. h = t - 0
  7250. }
  7251. if (f.call(a, x, h, w) === false) {
  7252. return false
  7253. }
  7254. }
  7255. }
  7256. },
  7257. getAllocationInfo : function(a) {
  7258. var b = [];
  7259. this.forEachAvailabilityIntervalWithTasks(a, function(h, g, f) {
  7260. var e = 0;
  7261. var c = [];
  7262. for (var d in f) {
  7263. e += f[d].units;
  7264. c.push(f[d].assignment)
  7265. }
  7266. b.push({
  7267. startDate : new Date(h),
  7268. endDate : new Date(g),
  7269. totalAllocation : e,
  7270. assignments : c
  7271. })
  7272. });
  7273. return b
  7274. }
  7275. });
  7276. Ext.define("Gnt.model.task.More", {
  7277. indent : function() {
  7278. var a = this.previousSibling;
  7279. if (a) {
  7280. this.isMove = true;
  7281. a.appendChild(this);
  7282. delete this.isMove;
  7283. a.set("leaf", false);
  7284. a.expand()
  7285. }
  7286. },
  7287. outdent : function() {
  7288. var a = this.parentNode;
  7289. if (a && !a.isRoot()) {
  7290. if (this.convertEmptyParentToLeaf) {
  7291. a.set("leaf", a.childNodes.length === 1)
  7292. }
  7293. this.isMove = true;
  7294. if (a.nextSibling) {
  7295. a.parentNode.insertBefore(this, a.nextSibling)
  7296. } else {
  7297. a.parentNode.appendChild(this)
  7298. }
  7299. delete this.isMove
  7300. }
  7301. },
  7302. getAllDependencies : function(a) {
  7303. a = a || this.getDependencyStore();
  7304. return a.getDependenciesForTask(this)
  7305. },
  7306. hasIncomingDependencies : function(a) {
  7307. var c = this.getId() || this.internalId;
  7308. a = a || this.getDependencyStore();
  7309. var b = a.findBy(function(d) {
  7310. return d.getTargetId() == c
  7311. });
  7312. return b >= 0
  7313. },
  7314. getIncomingDependencies : function(a) {
  7315. a = a || this.getDependencyStore();
  7316. return a.getIncomingDependenciesForTask(this)
  7317. },
  7318. getOutgoingDependencies : function(a) {
  7319. a = a || this.getDependencyStore();
  7320. return a.getOutgoingDependenciesForTask(this)
  7321. },
  7322. constrain : function(c) {
  7323. if (this.isManuallyScheduled()) {
  7324. return false
  7325. }
  7326. var e = false;
  7327. c = c || this.getTaskStore();
  7328. var b = this.getConstrainContext(c);
  7329. if (b) {
  7330. var a = b.startDate;
  7331. var d = b.endDate;
  7332. if (a && a - this.getStartDate() !== 0) {
  7333. this.setStartDate(a, true, c.skipWeekendsDuringDragDrop);
  7334. e = true
  7335. } else {
  7336. if (d && d - this.getEndDate() !== 0) {
  7337. this.setEndDate(d, true, c.skipWeekendsDuringDragDrop);
  7338. e = true
  7339. }
  7340. }
  7341. }
  7342. return e
  7343. },
  7344. getConstrainContext : function(f) {
  7345. var g = this.getIncomingDependencies();
  7346. if (!g.length) {
  7347. return null
  7348. }
  7349. var h = f || this.getTaskStore(), a = Gnt.model.Dependency.Type, c = new Date(0), b = new Date(0), i = Ext.Date, e = this
  7350. .getProjectCalendar(), d;
  7351. Ext.each(g, function(l) {
  7352. var k = l.getSourceTask();
  7353. if (k) {
  7354. var o = l.getLag() || 0, m = l.getLagUnit(), n = k
  7355. .getStartDate(), j = k.getEndDate();
  7356. switch (l.getType()) {
  7357. case a.StartToEnd :
  7358. n = e.skipWorkingTime(n, o, m);
  7359. if (b < n) {
  7360. b = n;
  7361. d = k
  7362. }
  7363. break;
  7364. case a.StartToStart :
  7365. n = e.skipWorkingTime(n, o, m);
  7366. if (c < n) {
  7367. c = n;
  7368. d = k
  7369. }
  7370. break;
  7371. case a.EndToStart :
  7372. j = e.skipWorkingTime(j, o, m);
  7373. if (c < j) {
  7374. c = j;
  7375. d = k
  7376. }
  7377. break;
  7378. case a.EndToEnd :
  7379. j = e.skipWorkingTime(j, o, m);
  7380. if (b < j) {
  7381. b = j;
  7382. d = k
  7383. }
  7384. break;
  7385. default :
  7386. throw "Invalid dependency type: " + l.getType()
  7387. }
  7388. }
  7389. });
  7390. return {
  7391. startDate : c > 0 ? c : null,
  7392. endDate : b > 0 ? b : null,
  7393. constrainingTask : d
  7394. }
  7395. },
  7396. getCriticalPaths : function() {
  7397. var b = [this], a = this.getConstrainContext();
  7398. while (a) {
  7399. b.push(a.constrainingTask);
  7400. a = a.constrainingTask.getConstrainContext()
  7401. }
  7402. return b
  7403. },
  7404. cascadeChanges : function(a, b, c) {
  7405. a = a || this.getTaskStore();
  7406. var d;
  7407. if (this.isLeaf()) {
  7408. d = this.constrain(a);
  7409. if (d) {
  7410. this.recalculateParents();
  7411. b.nbrAffected++
  7412. }
  7413. }
  7414. if (d) {
  7415. Ext.each(this.getOutgoingDependencies(), function(e) {
  7416. var f = e.getTargetTask();
  7417. if (f && !f.isManuallyScheduled()) {
  7418. f.cascadeChanges(a, b, e)
  7419. }
  7420. })
  7421. }
  7422. },
  7423. addSubtask : function(a) {
  7424. this.set("leaf", false);
  7425. this.appendChild(a);
  7426. this.expand();
  7427. return a
  7428. },
  7429. addSuccessor : function(b) {
  7430. var c = this.rec, e = this.getTaskStore(), d = this
  7431. .getDependencyStore();
  7432. b = b || new this.self();
  7433. b.calendar = b.calendar || this.getCalendar();
  7434. b.taskStore = e;
  7435. b.setStartDate(this.getEndDate(), true, e.skipWeekendsDuringDragDrop);
  7436. b.setDuration(1, Sch.util.Date.DAY);
  7437. this.addTaskBelow(b);
  7438. var a = new d.model({
  7439. fromTask : this,
  7440. toTask : b,
  7441. type : d.model.Type.EndToStart
  7442. });
  7443. d.add(a);
  7444. return b
  7445. },
  7446. addMilestone : function(c) {
  7447. var b = this.getTaskStore();
  7448. c = c || new this.self();
  7449. var a = this.getEndDate();
  7450. if (a) {
  7451. c.calendar = c.calendar || this.getCalendar();
  7452. c.setStartEndDate(a, a, b.skipWeekendsDuringDragDrop)
  7453. }
  7454. return this.addTaskBelow(c)
  7455. },
  7456. addPredecessor : function(c) {
  7457. var b = this.getDependencyStore();
  7458. c = c || new this.self();
  7459. c.calendar = c.calendar || this.getCalendar();
  7460. c.beginEdit();
  7461. c.set(this.startDateField, c.calculateStartDate(this.getStartDate(), 1,
  7462. Sch.util.Date.DAY));
  7463. c.set(this.endDateField, this.getStartDate());
  7464. c.set(this.durationField, 1);
  7465. c.set(this.durationUnitField, Sch.util.Date.DAY);
  7466. c.endEdit();
  7467. this.addTaskAbove(c);
  7468. var a = new b.model({
  7469. fromTask : c,
  7470. toTask : this,
  7471. type : b.model.Type.EndToStart
  7472. });
  7473. b.add(a);
  7474. return c
  7475. },
  7476. getSuccessors : function() {
  7477. var h = this.getId() || this.internalId;
  7478. var e = e || this.getDependencyStore();
  7479. var c = this.getTaskStore(), g = [];
  7480. for (var f = 0, a = e.getCount(); f < a; f++) {
  7481. var d = e.getAt(f);
  7482. if (d.getSourceId() == h) {
  7483. var b = d.getTargetTask();
  7484. if (b) {
  7485. g.push(b)
  7486. }
  7487. }
  7488. }
  7489. return g
  7490. },
  7491. getPredecessors : function() {
  7492. var g = this.getId() || this.internalId;
  7493. var d = d || this.getDependencyStore();
  7494. var b = this.getTaskStore(), f = [];
  7495. for (var e = 0, a = d.getCount(); e < a; e++) {
  7496. var c = d.getAt(e);
  7497. if (c.getTargetId() == g) {
  7498. f.push(c.getSourceTask())
  7499. }
  7500. }
  7501. return f
  7502. },
  7503. addTaskAbove : function(a) {
  7504. a = a || new this.self();
  7505. return this.parentNode.insertBefore(a, this)
  7506. },
  7507. addTaskBelow : function(a) {
  7508. a = a || new this.self();
  7509. if (this.nextSibling) {
  7510. return this.parentNode.insertBefore(a, this.nextSibling)
  7511. } else {
  7512. return this.parentNode.appendChild(a)
  7513. }
  7514. },
  7515. isAbove : function(a) {
  7516. var b = this, c = Math.min(b.data.depth, a.data.depth);
  7517. while (b.data.depth > c) {
  7518. b = b.parentNode
  7519. }
  7520. while (a.data.depth > c) {
  7521. a = a.parentNode
  7522. }
  7523. while (a.parentNode !== b.parentNode) {
  7524. a = a.parentNode;
  7525. b = b.parentNode
  7526. }
  7527. return a.data.index > b.data.index
  7528. },
  7529. cascadeChildren : function(a, c, b) {
  7530. this.cascadeBy(function(d) {
  7531. if (d !== a) {
  7532. return c.call(b || d, d)
  7533. }
  7534. })
  7535. }
  7536. });
  7537. Ext.define("Gnt.model.Task", {
  7538. extend : "Sch.model.Range",
  7539. requires : ["Sch.util.Date", "Ext.data.NodeInterface"],
  7540. mixins : ["Gnt.model.task.More"],
  7541. idProperty : "Id",
  7542. customizableFields : [{
  7543. name : "Id"
  7544. }, {
  7545. name : "Duration",
  7546. type : "number",
  7547. useNull : true
  7548. }, {
  7549. name : "Effort",
  7550. type : "number",
  7551. useNull : true
  7552. }, {
  7553. name : "EffortUnit",
  7554. type : "string",
  7555. defaultValue : "h"
  7556. }, {
  7557. name : "CalendarId",
  7558. type : "string"
  7559. }, {
  7560. name : "DurationUnit",
  7561. type : "string",
  7562. defaultValue : "d",
  7563. convert : function(a) {
  7564. return a || "d"
  7565. }
  7566. }, {
  7567. name : "PercentDone",
  7568. type : "int",
  7569. defaultValue : 0
  7570. }, {
  7571. name : "ManuallyScheduled",
  7572. type : "boolean",
  7573. defaultValue : false
  7574. }, {
  7575. name : "SchedulingMode",
  7576. type : "string",
  7577. defaultValue : "Normal"
  7578. }, {
  7579. name : "BaselineStartDate",
  7580. type : "date",
  7581. dateFormat : "c"
  7582. }, {
  7583. name : "BaselineEndDate",
  7584. type : "date",
  7585. dateFormat : "c"
  7586. }, {
  7587. name : "BaselinePercentDone",
  7588. type : "int",
  7589. defaultValue : 0
  7590. }, {
  7591. name : "Draggable",
  7592. type : "boolean",
  7593. persist : false,
  7594. defaultValue : true
  7595. }, {
  7596. name : "Resizable",
  7597. persist : false
  7598. }, {
  7599. name : "PhantomId",
  7600. type : "string"
  7601. }, {
  7602. name : "PhantomParentId",
  7603. type : "string"
  7604. }],
  7605. draggableField : "Draggable",
  7606. resizableField : "Resizable",
  7607. nameField : "Name",
  7608. durationField : "Duration",
  7609. durationUnitField : "DurationUnit",
  7610. effortField : "Effort",
  7611. effortUnitField : "EffortUnit",
  7612. percentDoneField : "PercentDone",
  7613. manuallyScheduledField : "ManuallyScheduled",
  7614. schedulingModeField : "SchedulingMode",
  7615. calendarIdField : "CalendarId",
  7616. baselineStartDateField : "BaselineStartDate",
  7617. baselineEndDateField : "BaselineEndDate",
  7618. baselinePercentDoneField : "BaselinePercentDone",
  7619. calendar : null,
  7620. dependencyStore : null,
  7621. taskStore : null,
  7622. phantomIdField : "PhantomId",
  7623. phantomParentIdField : "PhantomParentId",
  7624. normalized : false,
  7625. recognizedSchedulingModes : ["Normal", "Manual", "FixedDuration",
  7626. "EffortDriven", "DynamicAssignment"],
  7627. convertEmptyParentToLeaf : true,
  7628. constructor : function() {
  7629. this.getModifiedFieldNames = function() {
  7630. if (this.__isFilling__) {
  7631. return []
  7632. }
  7633. delete this.getModifiedFieldNames;
  7634. return this.getModifiedFieldNames.apply(this, arguments)
  7635. };
  7636. this.callParent(arguments);
  7637. if (this.phantom) {
  7638. this.data[this.phantomIdField] = this.internalId
  7639. }
  7640. },
  7641. normalize : function() {
  7642. var c = this.getDuration(), g = this.getDurationUnit(), b = this
  7643. .getStartDate(), f = this.getEndDate(), e = this
  7644. .getSchedulingMode(), d = this.data;
  7645. if (f && this.inclusiveEndDate) {
  7646. var i = this.fields.getByKey(this.endDateField).dateFormat;
  7647. var a = (i && !Ext.Date.formatContainsHourInfo(i))
  7648. || (f.getHours() === 0 && f.getMinutes() === 0
  7649. && f.getSeconds() === 0 && f.getMilliseconds() === 0);
  7650. if (a) {
  7651. if (Ext.isNumber(c)) {
  7652. f = d[this.endDateField] = this.calculateEndDate(b, c, g)
  7653. } else {
  7654. f = d[this.endDateField] = Ext.Date.add(f, Ext.Date.DAY, 1)
  7655. }
  7656. }
  7657. }
  7658. if (c == null && b && f) {
  7659. d[this.durationField] = this.calculateDuration(b, f, g)
  7660. }
  7661. if ((e == "Normal" || this.isManuallyScheduled()) && f == null && b
  7662. && Ext.isNumber(c)) {
  7663. d[this.endDateField] = this.calculateEndDate(b, c, g)
  7664. }
  7665. if (e == "EffortDriven" || e == "FixedDuration") {
  7666. var j = this.get(this.effortField), h = this.getEffortUnit();
  7667. if (j == null && b && f) {
  7668. d[this.effortField] = this.calculateEffort(b, f, h)
  7669. }
  7670. if (f == null && b && j) {
  7671. d[this.endDateField] = this.calculateEffortDrivenEndDate(b, j,
  7672. h);
  7673. if (c == null) {
  7674. d[this.durationField] = this.calculateDuration(b,
  7675. d[this.endDateField], g)
  7676. }
  7677. }
  7678. }
  7679. this.normalized = true
  7680. },
  7681. normalizeEffort : function() {
  7682. var c = this.childNodes;
  7683. var b = 0;
  7684. for (var a = 0; a < c.length; a++) {
  7685. var d = c[a];
  7686. if (!d.isLeaf()) {
  7687. d.normalizeEffort()
  7688. }
  7689. b += d.getEffort("MILLI")
  7690. }
  7691. if (this.getEffort("MILLI") != b) {
  7692. this.data[this.effortField] = this.getProjectCalendar()
  7693. .convertMSDurationToUnit(b, this.getEffortUnit())
  7694. }
  7695. },
  7696. getInternalId : function() {
  7697. return this.getId() || this.internalId
  7698. },
  7699. getCalendar : function(a) {
  7700. return a ? this.getOwnCalendar() : this.getOwnCalendar()
  7701. || this.getProjectCalendar()
  7702. },
  7703. getOwnCalendar : function() {
  7704. var a = this.get(this.calendarIdField);
  7705. return a ? Gnt.data.Calendar.getCalendar(a) : this.calendar
  7706. },
  7707. getProjectCalendar : function() {
  7708. var a = this.stores[0];
  7709. var b = a && a.getCalendar && a.getCalendar() || this.parentNode
  7710. && this.parentNode.getProjectCalendar() || this.isRoot()
  7711. && this.calendar;
  7712. if (!b) {
  7713. Ext.Error
  7714. .raise("Can't find a project calendar in `getProjectCalendar`")
  7715. }
  7716. return b
  7717. },
  7718. setCalendar : function(a) {
  7719. this.calendar = a
  7720. },
  7721. getDependencyStore : function() {
  7722. var a = this.dependencyStore || this.getTaskStore().dependencyStore;
  7723. if (!a) {
  7724. Ext.Error
  7725. .raise("Can't find a dependencyStore in `getDependencyStore`")
  7726. }
  7727. return a
  7728. },
  7729. getResourceStore : function() {
  7730. return this.getTaskStore().getResourceStore()
  7731. },
  7732. getAssignmentStore : function() {
  7733. return this.getTaskStore().getAssignmentStore()
  7734. },
  7735. getTaskStore : function(b) {
  7736. if (this.taskStore) {
  7737. return this.taskStore
  7738. }
  7739. var a = this.stores[0] && this.stores[0].taskStore || this.parentNode
  7740. && this.parentNode.getTaskStore(b);
  7741. if (!a && !b) {
  7742. Ext.Error.raise("Can't find a taskStore in `getTaskStore`")
  7743. }
  7744. return this.taskStore = a
  7745. },
  7746. isManuallyScheduled : function() {
  7747. return this.get(this.schedulingModeField) == "Manual"
  7748. || this.get(this.manuallyScheduledField)
  7749. },
  7750. setManuallyScheduled : function(a) {
  7751. if (a) {
  7752. this.set(this.schedulingModeField, "Manual")
  7753. } else {
  7754. if (this.get(this.schedulingModeField) == "Manual") {
  7755. this.set(this.schedulingModeField, "Normal")
  7756. }
  7757. }
  7758. return this.set(this.manuallyScheduledField, a)
  7759. },
  7760. setSchedulingMode : function(a) {
  7761. if (!Ext.Array.contains(this.recognizedSchedulingModes, a)) {
  7762. throw "Unrecognized scheduling mode: " + a
  7763. }
  7764. this.beginEdit();
  7765. this.set(this.schedulingModeField, a);
  7766. if (a === "FixedDuration") {
  7767. this.updateEffortBasedOnDuration()
  7768. }
  7769. if (a === "EffortDriven") {
  7770. this.updateDurationBasedOnEffort()
  7771. }
  7772. this.endEdit()
  7773. },
  7774. skipNonWorkingTime : function(b, c) {
  7775. var a = false;
  7776. this.forEachAvailabilityIntervalWithResources(c ? {
  7777. startDate : b
  7778. } : {
  7779. endDate : b,
  7780. isForward : false
  7781. }, function(f, e, d) {
  7782. b = c ? f : e;
  7783. a = true;
  7784. return false
  7785. });
  7786. return a ? new Date(b) : this.getCalendar().skipNonWorkingTime(b, c)
  7787. },
  7788. setStartDate : function(a, f, e) {
  7789. this.beginEdit();
  7790. if (!a) {
  7791. this.set(this.durationField, null);
  7792. this.set(this.startDateField, null)
  7793. } else {
  7794. var d = this.getCalendar();
  7795. if (e && !this.isManuallyScheduled()) {
  7796. if (!this.isMilestone() || d.isHoliday(a - 1)) {
  7797. a = this.skipNonWorkingTime(a, true)
  7798. }
  7799. }
  7800. var b = this.getSchedulingMode();
  7801. this.set(this.startDateField, a);
  7802. if (f !== false) {
  7803. if (b == "EffortDriven") {
  7804. this.set(this.endDateField, this
  7805. .calculateEffortDrivenEndDate(a, this
  7806. .getEffort()))
  7807. } else {
  7808. var c = this.getDuration();
  7809. if (Ext.isNumber(c)) {
  7810. this.set(this.endDateField, this.calculateEndDate(a, c,
  7811. this.getDurationUnit()))
  7812. }
  7813. }
  7814. } else {
  7815. if (this.getEndDate()) {
  7816. this.set(this.durationField, this.calculateDuration(a, this
  7817. .getEndDate(), this
  7818. .getDurationUnit()))
  7819. }
  7820. }
  7821. }
  7822. this.onPotentialEffortChange();
  7823. this.endEdit()
  7824. },
  7825. setEndDate : function(a, e, d) {
  7826. this.beginEdit();
  7827. if (!a) {
  7828. this.set(this.durationField, null);
  7829. this.set(this.endDateField, null)
  7830. } else {
  7831. var c = this.getCalendar();
  7832. if (d && !this.isManuallyScheduled()) {
  7833. a = this.skipNonWorkingTime(a, false)
  7834. }
  7835. if (e !== false) {
  7836. var b = this.getDuration();
  7837. if (Ext.isNumber(b)) {
  7838. this.set(this.startDateField, this.calculateStartDate(a, b,
  7839. this.getDurationUnit()));
  7840. this.set(this.endDateField, a)
  7841. } else {
  7842. this.set(this.endDateField, a)
  7843. }
  7844. } else {
  7845. this.set(this.endDateField, a);
  7846. if (this.getStartDate()) {
  7847. this.set(this.durationField, this.calculateDuration(this
  7848. .getStartDate(), a, this
  7849. .getDurationUnit()))
  7850. }
  7851. }
  7852. }
  7853. this.onPotentialEffortChange();
  7854. this.endEdit()
  7855. },
  7856. setStartEndDate : function(a, b, c) {
  7857. this.beginEdit();
  7858. if (c && !this.isManuallyScheduled()) {
  7859. a = a && this.skipNonWorkingTime(a, true);
  7860. b = b && this.skipNonWorkingTime(b, false)
  7861. }
  7862. this.set(this.startDateField, a);
  7863. this.set(this.endDateField, b);
  7864. this.set(this.durationField, this.calculateDuration(a, b, this
  7865. .getDurationUnit()));
  7866. this.onPotentialEffortChange();
  7867. this.endEdit()
  7868. },
  7869. getDuration : function(a) {
  7870. if (!a) {
  7871. return this.get(this.durationField)
  7872. }
  7873. var b = this.getProjectCalendar(), c = b.convertDurationToMs(this
  7874. .get(this.durationField), this
  7875. .get(this.durationUnitField));
  7876. return b.convertMSDurationToUnit(c, a)
  7877. },
  7878. getEffort : function(a) {
  7879. var b = this.get(this.effortField) || 0;
  7880. if (!a) {
  7881. return b
  7882. }
  7883. var c = this.getProjectCalendar(), d = c.convertDurationToMs(b, this
  7884. .getEffortUnit());
  7885. return c.convertMSDurationToUnit(d, a)
  7886. },
  7887. setEffort : function(b, a) {
  7888. a = a || this.get(this.effortUnitField);
  7889. this.beginEdit();
  7890. this.set(this.effortField, b);
  7891. this.set(this.effortUnitField, a);
  7892. if (this.getSchedulingMode() === "EffortDriven") {
  7893. this.updateDurationBasedOnEffort()
  7894. }
  7895. if (this.getSchedulingMode() === "DynamicAssignment") {
  7896. this.updateAssignments()
  7897. }
  7898. this.endEdit()
  7899. },
  7900. getCalendarDuration : function(a) {
  7901. return this.getProjectCalendar().convertMSDurationToUnit(
  7902. this.getEndDate() - this.getStartDate(),
  7903. a || this.get(this.durationUnitField))
  7904. },
  7905. setDuration : function(d, c) {
  7906. c = c || this.get(this.durationUnitField);
  7907. this.beginEdit();
  7908. if (Ext.isNumber(d) && !this.getStartDate()) {
  7909. var a = new Date();
  7910. Ext.Date.clearTime(a);
  7911. this.setStartDate(a)
  7912. }
  7913. var b = null;
  7914. if (Ext.isNumber(d)) {
  7915. b = this.calculateEndDate(this.getStartDate(), d, c)
  7916. }
  7917. this.set(this.endDateField, b);
  7918. this.set(this.durationField, d);
  7919. this.set(this.durationUnitField, c);
  7920. this.onPotentialEffortChange();
  7921. this.endEdit()
  7922. },
  7923. calculateStartDate : function(e, d, c) {
  7924. c = c || this.getDurationUnit();
  7925. if (this.isManuallyScheduled()) {
  7926. return Sch.util.Date.add(a, c, -d)
  7927. } else {
  7928. if (this.getTaskStore(true) && this.hasAssignments()) {
  7929. var b = this.getProjectCalendar().convertDurationToMs(d,
  7930. c || this.getDurationUnit());
  7931. var a;
  7932. this.forEachAvailabilityIntervalWithResources({
  7933. endDate : e,
  7934. isForward : false
  7935. }, function(i, h, g) {
  7936. var f = h - i;
  7937. if (f >= b) {
  7938. a = new Date(h - b);
  7939. return false
  7940. } else {
  7941. b -= f
  7942. }
  7943. });
  7944. return a
  7945. } else {
  7946. return this.getCalendar().calculateStartDate(e, d, c)
  7947. }
  7948. }
  7949. },
  7950. calculateEndDate : function(a, f, d) {
  7951. d = d || this.getDurationUnit();
  7952. if (this.isManuallyScheduled()) {
  7953. return Sch.util.Date.add(a, d, f)
  7954. } else {
  7955. var c = this.getSchedulingMode();
  7956. if (this.getTaskStore(true) && this.hasAssignments()
  7957. && c != "FixedDuration" && c != "DynamicAssignment"
  7958. && c != "EffortDriven") {
  7959. var b = this.getProjectCalendar().convertDurationToMs(f,
  7960. d || this.getDurationUnit());
  7961. var e;
  7962. this.forEachAvailabilityIntervalWithResources({
  7963. startDate : a
  7964. }, function(j, i, h) {
  7965. var g = i - j;
  7966. if (g >= b) {
  7967. e = new Date(j + b);
  7968. return false
  7969. } else {
  7970. b -= g
  7971. }
  7972. });
  7973. return e
  7974. } else {
  7975. return this.getCalendar().calculateEndDate(a, f, d)
  7976. }
  7977. }
  7978. },
  7979. calculateDuration : function(a, c, b) {
  7980. b = b || this.getDurationUnit();
  7981. if (!a || !c) {
  7982. return 0
  7983. }
  7984. if (this.isManuallyScheduled()) {
  7985. return this.getProjectCalendar().convertMSDurationToUnit(c - a, b)
  7986. } else {
  7987. if (this.getTaskStore(true) && this.hasAssignments()) {
  7988. var d = 0;
  7989. this.forEachAvailabilityIntervalWithResources({
  7990. startDate : a,
  7991. endDate : c
  7992. }, function(g, f, e) {
  7993. d += f - g
  7994. });
  7995. return this.getProjectCalendar().convertMSDurationToUnit(d, b)
  7996. } else {
  7997. return this.getCalendar().calculateDuration(a, c, b)
  7998. }
  7999. }
  8000. },
  8001. forEachAvailabilityIntervalWithResources : function(f, h, a) {
  8002. a = a || this;
  8003. var C = this;
  8004. var d = f.startDate;
  8005. var z = f.endDate;
  8006. var p = f.isForward !== false;
  8007. if (p ? !d : !z) {
  8008. throw new Error("At least `startDate` or `endDate` is required, depending from the `isForward` option")
  8009. }
  8010. var j = new Date(p ? d : z);
  8011. var b = f.includeEmptyIntervals;
  8012. var c = this.getOwnCalendar();
  8013. var G = Boolean(c);
  8014. var E = this.getProjectCalendar();
  8015. var A, v, r;
  8016. if (f.resources) {
  8017. A = f.resources;
  8018. r = [];
  8019. v = [];
  8020. Ext.each(A, function(i) {
  8021. v.push(i.getCalendar());
  8022. r.push(C.getAssignmentFor(i))
  8023. })
  8024. } else {
  8025. r = this.getAssignments();
  8026. if (!r.length) {
  8027. return
  8028. }
  8029. A = [];
  8030. v = [];
  8031. Ext.each(r, function(k) {
  8032. var i = k.getResource();
  8033. A.push(i);
  8034. v.push(i.getCalendar())
  8035. })
  8036. }
  8037. var g = Sch.util.Date;
  8038. var y, u, B, D, n;
  8039. var t = p ? !z : !d;
  8040. while (t || (p ? j < z : j > d)) {
  8041. var q = {};
  8042. var F = [];
  8043. if (G) {
  8044. var l = c.getAvailabilityIntervalsFor(j - (p ? 0 : 1));
  8045. for (u = 0; u < l.length; u++) {
  8046. B = l[u];
  8047. D = B.startDate - 0;
  8048. n = B.endDate - 0;
  8049. if (!q[D]) {
  8050. q[D] = [];
  8051. F.push(D)
  8052. }
  8053. q[D].push({
  8054. type : "00-taskAvailailabilityStart",
  8055. typeBackward : "01-taskAvailailabilityStart"
  8056. });
  8057. F.push(n);
  8058. q[n] = q[n] || [];
  8059. q[n].push({
  8060. type : "01-taskAvailailabilityEnd",
  8061. typeBackward : "00-taskAvailailabilityEnd"
  8062. })
  8063. }
  8064. }
  8065. for (y = 0; y < v.length; y++) {
  8066. var e = v[y].getAvailabilityIntervalsFor(j);
  8067. for (u = 0; u < e.length; u++) {
  8068. B = e[u];
  8069. D = B.startDate - 0;
  8070. n = B.endDate - 0;
  8071. if (!q[D]) {
  8072. q[D] = [];
  8073. F.push(D)
  8074. }
  8075. q[D].push({
  8076. type : "02-resourceAvailailabilityStart",
  8077. typeBackward : "03-resourceAvailailabilityStart",
  8078. assignment : r[y],
  8079. resourceId : A[y].getInternalId(),
  8080. units : r[y].getUnits()
  8081. });
  8082. if (!q[n]) {
  8083. q[n] = [];
  8084. F.push(n)
  8085. }
  8086. q[n].push({
  8087. type : "03-resourceAvailailabilityEnd",
  8088. typeBackward : "02-resourceAvailailabilityEnd",
  8089. assignment : r[y],
  8090. resourceId : A[y].getInternalId(),
  8091. units : r[y].getUnits()
  8092. })
  8093. }
  8094. }
  8095. F.sort();
  8096. var x = false;
  8097. var o = {};
  8098. var m = 0;
  8099. var w, s;
  8100. if (p) {
  8101. for (y = 0; y < F.length; y++) {
  8102. w = q[F[y]];
  8103. w.sort(function(k, i) {
  8104. return k.type < i.type
  8105. });
  8106. for (u = 0; u < w.length; u++) {
  8107. s = w[u];
  8108. if (s.type == "00-taskAvailailabilityStart") {
  8109. x = true
  8110. }
  8111. if (s.type == "01-taskAvailailabilityEnd") {
  8112. x = false
  8113. }
  8114. if (s.type == "02-resourceAvailailabilityStart") {
  8115. o[s.resourceId] = s;
  8116. m++
  8117. }
  8118. if (s.type == "03-resourceAvailailabilityEnd") {
  8119. delete o[s.resourceId];
  8120. m--
  8121. }
  8122. }
  8123. if ((x || !G) && (m || b)) {
  8124. D = F[y];
  8125. n = F[y + 1];
  8126. if (D >= z || n <= d) {
  8127. continue
  8128. }
  8129. if (D < d) {
  8130. D = d - 0
  8131. }
  8132. if (n > z) {
  8133. n = z - 0
  8134. }
  8135. if (h.call(a, D, n, o) === false) {
  8136. return false
  8137. }
  8138. }
  8139. }
  8140. } else {
  8141. for (y = F.length - 1; y >= 0; y--) {
  8142. w = q[F[y]];
  8143. w.sort(function(k, i) {
  8144. return k.typeBackward < i.typeBackward
  8145. });
  8146. for (u = 0; u < w.length; u++) {
  8147. s = w[u];
  8148. if (s.typeBackward == "00-taskAvailailabilityEnd") {
  8149. x = true
  8150. }
  8151. if (s.typeBackward == "01-taskAvailailabilityStart") {
  8152. x = false
  8153. }
  8154. if (s.typeBackward == "02-resourceAvailailabilityEnd") {
  8155. o[s.resourceId] = s;
  8156. m++
  8157. }
  8158. if (s.typeBackward == "03-resourceAvailailabilityStart") {
  8159. delete o[s.resourceId];
  8160. m--
  8161. }
  8162. }
  8163. if ((x || !G) && (m || b)) {
  8164. D = F[y - 1];
  8165. n = F[y];
  8166. if (D > z || n <= d) {
  8167. continue
  8168. }
  8169. if (D < d) {
  8170. D = d - 0
  8171. }
  8172. if (n > z) {
  8173. n = z - 0
  8174. }
  8175. if (h.call(a, D, n, o) === false) {
  8176. return false
  8177. }
  8178. }
  8179. }
  8180. }
  8181. j = p ? g.getStartOfNextDay(j) : g.getEndOfPreviousDay(j)
  8182. }
  8183. },
  8184. calculateEffortDrivenEndDate : function(a, c, b) {
  8185. var e = this.getProjectCalendar().convertDurationToMs(c,
  8186. b || this.getEffortUnit());
  8187. var d = new Date(a);
  8188. this.forEachAvailabilityIntervalWithResources({
  8189. startDate : a
  8190. }, function(l, k, j) {
  8191. var m = 0;
  8192. for (var h in j) {
  8193. m += j[h].units
  8194. }
  8195. var g = k - l;
  8196. var f = m * g / 100;
  8197. if (f >= e) {
  8198. d = new Date(l + e / f * g);
  8199. return false
  8200. } else {
  8201. e -= f
  8202. }
  8203. });
  8204. return d
  8205. },
  8206. recalculateParents : function() {
  8207. var h = new Date(9999, 0, 0), e = new Date(0), m = this.parentNode;
  8208. if (m && m.childNodes.length > 0) {
  8209. var b = 0;
  8210. for (var f = 0, j = m.childNodes.length; f < j; f++) {
  8211. b += m.childNodes[f].getEffort("MILLI")
  8212. }
  8213. if (m.getEffort("MILLI") != b) {
  8214. m.setEffort(this.getProjectCalendar().convertMSDurationToUnit(
  8215. b, m.getEffortUnit()))
  8216. }
  8217. }
  8218. var n, c;
  8219. if (m && !m.isRoot() && m.childNodes.length > 0) {
  8220. if (!m.isManuallyScheduled()) {
  8221. for (var g = 0, d = m.childNodes.length; g < d; g++) {
  8222. var a = m.childNodes[g];
  8223. h = Sch.util.Date.min(h, a.getStartDate() || h);
  8224. e = Sch.util.Date.max(e, a.getEndDate() || e)
  8225. }
  8226. n = h - new Date(9999, 0, 0) !== 0
  8227. && m.getStartDate() - h !== 0;
  8228. c = e - new Date(0) !== 0 && m.getEndDate() - e !== 0;
  8229. if (n && c) {
  8230. m.setStartEndDate(h, e, false)
  8231. } else {
  8232. if (n) {
  8233. m.setStartDate(h, c, false)
  8234. } else {
  8235. if (c) {
  8236. m.setEndDate(e, false, false)
  8237. }
  8238. }
  8239. }
  8240. }
  8241. if (!n && !c) {
  8242. m.recalculateParents()
  8243. }
  8244. }
  8245. },
  8246. isMilestone : function() {
  8247. return this.getDuration() === 0
  8248. },
  8249. isBaselineMilestone : function() {
  8250. var b = this.getBaselineStartDate(), a = this.getBaselineEndDate();
  8251. if (b && a) {
  8252. return a - b === 0
  8253. }
  8254. return false
  8255. },
  8256. afterEdit : function(b) {
  8257. if (this.stores.length > 0 || !this.normalized) {
  8258. this.callParent(arguments)
  8259. } else {
  8260. var a = this.taskStore || this.getTaskStore(true);
  8261. if (a && !a.isFillingRoot) {
  8262. a.afterEdit(this, b)
  8263. }
  8264. this.callParent(arguments)
  8265. }
  8266. },
  8267. afterCommit : function() {
  8268. this.callParent(arguments);
  8269. if (this.stores.length > 0 || !this.normalized) {
  8270. return
  8271. }
  8272. var a = this.taskStore || this.getTaskStore(true);
  8273. if (a && !a.isFillingRoot) {
  8274. a.afterCommit(this)
  8275. }
  8276. },
  8277. afterReject : function() {
  8278. if (this.stores.length > 0) {
  8279. this.callParent(arguments)
  8280. } else {
  8281. var a = this.getTaskStore(true);
  8282. if (a && !a.isFillingRoot) {
  8283. a.afterReject(this)
  8284. }
  8285. this.callParent(arguments)
  8286. }
  8287. },
  8288. getDurationUnit : function() {
  8289. return this.get(this.durationUnitField) || "d"
  8290. },
  8291. getEffortUnit : function() {
  8292. return this.get(this.effortUnitField) || "h"
  8293. },
  8294. getBaselinePercentDone : function() {
  8295. return this.get(this.baselinePercentDoneField) || 0
  8296. },
  8297. isPersistable : function() {
  8298. var a = this.parentNode;
  8299. return !a.phantom
  8300. },
  8301. getResources : function() {
  8302. var b = this.getAssignmentStore(), c = this.getInternalId();
  8303. var a = [];
  8304. if (b) {
  8305. b.each(function(d) {
  8306. if (d.getTaskId() == c) {
  8307. a.push(d.getResource())
  8308. }
  8309. })
  8310. }
  8311. return a
  8312. },
  8313. getAssignments : function() {
  8314. var b = this.getAssignmentStore(), c = this.getInternalId();
  8315. var a = [];
  8316. if (b) {
  8317. b.each(function(d) {
  8318. if (d.getTaskId() == c) {
  8319. a.push(d)
  8320. }
  8321. })
  8322. }
  8323. return a
  8324. },
  8325. hasAssignments : function() {
  8326. var b = this.getAssignmentStore(), c = this.getInternalId();
  8327. var a = false;
  8328. if (b) {
  8329. b.each(function(d) {
  8330. if (d.getTaskId() == c) {
  8331. a = true;
  8332. return false
  8333. }
  8334. })
  8335. }
  8336. return a
  8337. },
  8338. getAssignmentFor : function(b) {
  8339. var c = this.getAssignmentStore(), e = this.getInternalId(), d = b instanceof Gnt.model.Resource
  8340. ? b.getInternalId()
  8341. : b;
  8342. var a;
  8343. if (c) {
  8344. c.each(function(f) {
  8345. if (f.getTaskId() == e && f.getResourceId() == d) {
  8346. a = f;
  8347. return false
  8348. }
  8349. })
  8350. }
  8351. return a || null
  8352. },
  8353. unassign : function() {
  8354. return this.unAssign.apply(this, arguments)
  8355. },
  8356. unAssign : function(c) {
  8357. var d = this.getAssignmentStore();
  8358. var b = this.getInternalId();
  8359. var e = c instanceof Gnt.model.Resource ? c.getInternalId() : c;
  8360. var a = d.findBy(function(f) {
  8361. return f.getResourceId() == e && f.getTaskId() == b
  8362. });
  8363. if (a >= 0) {
  8364. d.removeAt(a)
  8365. }
  8366. },
  8367. assign : function(e, a) {
  8368. var b = this.getTaskStore(), h = this.getInternalId(), f = b
  8369. .getAssignmentStore(), d = b.getResourceStore();
  8370. var g = e instanceof Gnt.model.Resource ? e.getInternalId() : e;
  8371. f.each(function(i) {
  8372. if (i.getTaskId() == h && i.getResourceId() == g) {
  8373. throw "Resource can't be assigned twice to the same task"
  8374. }
  8375. });
  8376. if (e instanceof Gnt.model.Resource && d.indexOf(e) == -1) {
  8377. d.add(e)
  8378. }
  8379. var c = new Gnt.model.Assignment({
  8380. TaskId : h,
  8381. ResourceId : g,
  8382. Units : a
  8383. });
  8384. f.add(c);
  8385. return c
  8386. },
  8387. calculateEffort : function(a, c, b) {
  8388. var d = 0;
  8389. this.forEachAvailabilityIntervalWithResources({
  8390. startDate : a,
  8391. endDate : c
  8392. }, function(h, g, f) {
  8393. var j = 0;
  8394. for (var e in f) {
  8395. j += f[e].units
  8396. }
  8397. d += (g - h) * j / 100
  8398. });
  8399. return this.getProjectCalendar().convertMSDurationToUnit(d,
  8400. b || this.getEffortUnit())
  8401. },
  8402. updateAssignments : function() {
  8403. var b = {};
  8404. var a = this.getStartDate();
  8405. var d = this.getEndDate();
  8406. var c = 0;
  8407. this.forEachAvailabilityIntervalWithResources({
  8408. startDate : a,
  8409. endDate : d
  8410. }, function(h, g, f) {
  8411. for (var i in f) {
  8412. c += g - h
  8413. }
  8414. });
  8415. if (!c) {
  8416. return
  8417. }
  8418. var e = this.getEffort(Sch.util.Date.MILLI);
  8419. Ext.Array.each(this.getAssignments(), function(f) {
  8420. f.setUnits(e / c * 100)
  8421. })
  8422. },
  8423. updateEffortBasedOnDuration : function() {
  8424. this.setEffort(this.calculateEffort(this.getStartDate(), this
  8425. .getEndDate()))
  8426. },
  8427. updateDurationBasedOnEffort : function() {
  8428. this.setEndDate(this.calculateEffortDrivenEndDate(this.getStartDate(),
  8429. this.getEffort(), this.getEffortUnit()), false)
  8430. },
  8431. onPotentialEffortChange : function() {
  8432. if (this.getSchedulingMode() === "FixedDuration") {
  8433. this.updateEffortBasedOnDuration()
  8434. }
  8435. if (this.getSchedulingMode() === "DynamicAssignment") {
  8436. this.updateAssignments()
  8437. }
  8438. },
  8439. onAssignmentMutation : function() {
  8440. if (this.getSchedulingMode() === "FixedDuration") {
  8441. this.updateEffortBasedOnDuration()
  8442. }
  8443. if (this.getSchedulingMode() === "EffortDriven") {
  8444. this.updateDurationBasedOnEffort()
  8445. }
  8446. },
  8447. onAssignmentStructureMutation : function() {
  8448. if (this.getSchedulingMode() == "FixedDuration") {
  8449. this.updateEffortBasedOnDuration()
  8450. }
  8451. if (this.getSchedulingMode() === "EffortDriven") {
  8452. this.updateDurationBasedOnEffort()
  8453. }
  8454. if (this.getSchedulingMode() === "DynamicAssignment") {
  8455. this.updateAssignments()
  8456. }
  8457. },
  8458. adjustToCalendar : function() {
  8459. if (this.get("leaf") && !this.isManuallyScheduled()) {
  8460. var a = this.hasIncomingDependencies();
  8461. if (a) {
  8462. this.constrain()
  8463. } else {
  8464. this.setStartDate(this.getStartDate(), true, true)
  8465. }
  8466. }
  8467. },
  8468. isEditable : function(a) {
  8469. if ((a === this.durationField || a === this.endDateField)
  8470. && this.getSchedulingMode() === "EffortDriven") {
  8471. return false
  8472. }
  8473. if (a === this.effortField
  8474. && this.getSchedulingMode() === "FixedDuration") {
  8475. return false
  8476. }
  8477. return true
  8478. },
  8479. isDraggable : function() {
  8480. return this.getDraggable()
  8481. },
  8482. isResizable : function() {
  8483. return this.getResizable()
  8484. },
  8485. ensureSingleSyncForMethod : function() {
  8486. return function() {
  8487. var a = this.getTaskStore(true);
  8488. var c;
  8489. if (a && a.autoSync && !a.autoSyncSuspended) {
  8490. c = true;
  8491. a.suspendAutoSync()
  8492. }
  8493. var b = this.callParent(arguments);
  8494. if (c) {
  8495. a.resumeAutoSync();
  8496. a.sync()
  8497. }
  8498. return b
  8499. }
  8500. },
  8501. getId : function() {
  8502. var a = this.data[this.idProperty];
  8503. return a && a !== "root" ? a : null
  8504. },
  8505. join : function(b) {
  8506. var a = this.store;
  8507. if (Ext.getVersion("extjs").isGreaterThanOrEqual("4.1.3") && a) {
  8508. if (b instanceof Ext.data.TreeStore && a.treeStore == b) {
  8509. return
  8510. }
  8511. if (b instanceof Ext.data.NodeStore && b.treeStore == a) {
  8512. this.unjoin(a)
  8513. }
  8514. }
  8515. this.callParent(arguments)
  8516. }
  8517. }, function() {
  8518. Ext.data.NodeInterface.decorate(this);
  8519. var a = ["addPredecessor", "addSubtask", "addSuccessor", "indent",
  8520. "outdent", "remove", "insertBefore", "appendChild"];
  8521. this.override({
  8522. remove : function() {
  8523. var b = this.parentNode;
  8524. var c = this.callParent(arguments);
  8525. if (b.convertEmptyParentToLeaf && b.childNodes.length === 0
  8526. && this.getTaskStore().recalculateParents) {
  8527. b.set("leaf", true)
  8528. }
  8529. return c
  8530. },
  8531. insertBefore : function(b) {
  8532. if (this.phantom) {
  8533. this.data[this.phantomIdField] = b.data[this.phantomParentIdField] = this.internalId
  8534. }
  8535. return this.callParent(arguments)
  8536. },
  8537. appendChild : function(b) {
  8538. if (this.phantom) {
  8539. this.data[this.phantomIdField] = b.data[this.phantomParentIdField] = this.internalId
  8540. }
  8541. return this.callParent(arguments)
  8542. }
  8543. });
  8544. Ext.each(a, function(c) {
  8545. var b = {};
  8546. b[c] = this.prototype
  8547. .ensureSingleSyncForMethod(this.prototype[c]);
  8548. this.override(b)
  8549. }, this)
  8550. });
  8551. Ext.define("Gnt.util.DurationParser", {
  8552. requires : ["Sch.util.Date"],
  8553. parseNumberFn : null,
  8554. durationRegex : null,
  8555. allowDecimals : true,
  8556. unitsRegex : {
  8557. MILLI : /^ms$|^mil/i,
  8558. SECOND : /^s$|^sec/i,
  8559. MINUTE : /^m$|^min/i,
  8560. HOUR : /^h$|^hr$|^hour/i,
  8561. DAY : /^d$|^day/i,
  8562. WEEK : /^w$|^wk|^week/i,
  8563. MONTH : /^mo|^mnt/i,
  8564. QUARTER : /^q$|^quar|^qrt/i,
  8565. YEAR : /^y$|^yr|^year/i
  8566. },
  8567. constructor : function(a) {
  8568. Ext.apply(this, a);
  8569. if (!this.durationRegex) {
  8570. this.durationRegex = this.allowDecimals
  8571. ? /^\s*([\-+]?\d+(?:[.,]\d+)?)\s*(\w+)?/i
  8572. : /^\s*([\-+]?\d+)(?![.,])\s*(\w+)?/i
  8573. }
  8574. },
  8575. parse : function(c) {
  8576. var a = this.durationRegex.exec(c);
  8577. if (c == null || !a) {
  8578. return null
  8579. }
  8580. var e = this.parseNumberFn(a[1]);
  8581. var b = a[2];
  8582. var d;
  8583. if (b) {
  8584. Ext.iterate(this.unitsRegex, function(f, g) {
  8585. if (g.test(b)) {
  8586. d = Sch.util.Date.getUnitByName(f);
  8587. return false
  8588. }
  8589. });
  8590. if (!d) {
  8591. return null
  8592. }
  8593. }
  8594. return {
  8595. value : e,
  8596. unit : d
  8597. }
  8598. }
  8599. });
  8600. Ext.define("Gnt.util.DependencyParser", {
  8601. requires : ["Gnt.util.DurationParser"],
  8602. separator : ";",
  8603. parseNumberFn : null,
  8604. dependencyRegex : /(-?\d+)(SS|SF|FS|FF)?([\+\-])?/i,
  8605. types : ["SS", "SF", "FS", "FF"],
  8606. constructor : function(a) {
  8607. this.durationParser = new Gnt.util.DurationParser(a);
  8608. Ext.apply(this, a)
  8609. },
  8610. parse : function(g) {
  8611. if (!g) {
  8612. return []
  8613. }
  8614. var c = g.split(this.separator);
  8615. var j = [];
  8616. var b = this.dependencyRegex;
  8617. for (var e = 0; e < c.length; e++) {
  8618. var f = b.exec(c[e]);
  8619. var d = {};
  8620. if (!f) {
  8621. return null
  8622. }
  8623. d.taskId = parseInt(f[1], 10);
  8624. if (!f[2] && f[3]) {
  8625. return null
  8626. }
  8627. d.type = this.types.indexOf((f[2] || "FS").toUpperCase());
  8628. var h = f[3];
  8629. if (h) {
  8630. var a = this.durationParser.parse(c[e].substring(c[e]
  8631. .indexOf(h)));
  8632. if (!a) {
  8633. return null
  8634. }
  8635. d.lag = a.value;
  8636. d.lagUnit = a.unit || "d"
  8637. }
  8638. j.push(d)
  8639. }
  8640. return j
  8641. }
  8642. });
  8643. Ext.define("Gnt.data.Calendar", {
  8644. extend : "Ext.data.Store",
  8645. requires : ["Ext.Date", "Gnt.model.CalendarDay", "Sch.model.Range",
  8646. "Sch.util.Date"],
  8647. model : "Gnt.model.CalendarDay",
  8648. daysPerMonth : 30,
  8649. daysPerWeek : 7,
  8650. hoursPerDay : 24,
  8651. unitsInMs : null,
  8652. defaultNonWorkingTimeCssCls : "gnt-holiday",
  8653. weekendsAreWorkdays : false,
  8654. weekendFirstDay : 6,
  8655. weekendSecondDay : 0,
  8656. holidaysCache : null,
  8657. availabilityIntervalsCache : null,
  8658. weekAvailability : null,
  8659. defaultWeekAvailability : null,
  8660. nonStandardWeeksByStartDate : null,
  8661. nonStandardWeeksStartDates : null,
  8662. calendarId : null,
  8663. parent : null,
  8664. defaultAvailability : ["00:00-24:00"],
  8665. name : null,
  8666. statics : {
  8667. getCalendar : function(a) {
  8668. if (a instanceof Gnt.data.Calendar) {
  8669. return a
  8670. }
  8671. return Ext.data.StoreManager.lookup("GNT_CALENDAR:" + a)
  8672. },
  8673. getAllCalendars : function() {
  8674. var a = [];
  8675. Ext.data.StoreManager.each(function(b) {
  8676. if (b instanceof Gnt.data.Calendar) {
  8677. a.push(b)
  8678. }
  8679. });
  8680. return a
  8681. }
  8682. },
  8683. constructor : function(a) {
  8684. a = a || {};
  8685. if (a.calendarId) {
  8686. this.storeId = "GNT_CALENDAR:" + a.calendarId
  8687. }
  8688. this.callParent(arguments);
  8689. var c = this;
  8690. var b = this.parent = Gnt.data.Calendar.getCalendar(a.parent);
  8691. if (a.parent && !this.parent) {
  8692. throw new Error("Invalid parent specified for calendar")
  8693. }
  8694. this.unitsInMs = {
  8695. MILLI : 1,
  8696. SECOND : 1000,
  8697. MINUTE : 60 * 1000,
  8698. HOUR : 60 * 60 * 1000,
  8699. DAY : this.hoursPerDay * 60 * 60 * 1000,
  8700. WEEK : this.daysPerWeek * this.hoursPerDay * 60 * 60 * 1000,
  8701. MONTH : this.daysPerMonth * this.hoursPerDay * 60 * 60 * 1000,
  8702. QUARTER : 3 * this.daysPerMonth * 24 * 60 * 60 * 1000,
  8703. YEAR : 4 * 3 * this.daysPerMonth * 24 * 60 * 60 * 1000
  8704. };
  8705. this.defaultWeekAvailability = this
  8706. .getDefaultWeekAvailability(this.weekendsAreWorkdays);
  8707. Ext.Array.each(a.weekAvailability || [], function(e, d) {
  8708. if (e) {
  8709. e.setDate(new Date(0, 0, d));
  8710. e.set(e.idProperty, "WEEKDAY:" + d)
  8711. }
  8712. c.add(e)
  8713. });
  8714. this.holidaysCache = {};
  8715. this.availabilityIntervalsCache = {};
  8716. this.on({
  8717. clear : this.clearCache,
  8718. datachanged : this.clearCache,
  8719. update : this.clearCache,
  8720. load : this.updateAvailability,
  8721. scope : this
  8722. });
  8723. b && b.on("clearcache", this.clearCache, this);
  8724. this.updateAvailability()
  8725. },
  8726. getDefaultWeekAvailability : function(f) {
  8727. if (arguments.length === 0) {
  8728. f = this.weekendsAreWorkdays
  8729. }
  8730. var e = this.defaultAvailability;
  8731. var d = this.weekendFirstDay;
  8732. var a = this.weekendSecondDay;
  8733. var c = [];
  8734. for (var b = 0; b < 7; b++) {
  8735. c.push(f || b != d && b != a ? new Gnt.model.CalendarDay({
  8736. Availability : Ext.Array.clone(e),
  8737. IsWorkingDay : true
  8738. }) : new Gnt.model.CalendarDay({
  8739. Availability : []
  8740. }))
  8741. }
  8742. return c
  8743. },
  8744. updateAvailability : function() {
  8745. var a = this.weekAvailability = [];
  8746. var c = this.nonStandardWeeksStartDates = [];
  8747. var b = this.nonStandardWeeksByStartDate = {};
  8748. this.each(function(e) {
  8749. var i = e.getId();
  8750. var g = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
  8751. .exec(i);
  8752. var f;
  8753. if (g) {
  8754. var d = Ext.Date.parse(g[2], "Y/m/d") - 0;
  8755. var h = Ext.Date.parse(g[3], "Y/m/d") - 0;
  8756. f = g[1];
  8757. if (!b[d]) {
  8758. b[d] = {
  8759. startDate : new Date(d),
  8760. endDate : new Date(h),
  8761. name : e.getName(),
  8762. weekAvailability : []
  8763. };
  8764. c.push(d)
  8765. }
  8766. b[d].weekAvailability[f] = e
  8767. }
  8768. g = /^WEEKDAY:(\d+)$/.exec(i);
  8769. if (g) {
  8770. f = g[1];
  8771. if (f < 0 || f > 6) {
  8772. throw new Error("Incorrect week day index")
  8773. }
  8774. a[f] = e
  8775. }
  8776. });
  8777. c.sort()
  8778. },
  8779. intersectsWithCurrentWeeks : function(b, d) {
  8780. var e = this.nonStandardWeeksStartDates;
  8781. var c = this.nonStandardWeeksByStartDate;
  8782. var a = false;
  8783. Ext.Array.each(e, function(h) {
  8784. var f = c[h].startDate;
  8785. var g = c[h].endDate;
  8786. if (f <= b && b < g || f < d && d <= g) {
  8787. a = true;
  8788. return false
  8789. }
  8790. });
  8791. return a
  8792. },
  8793. addNonStandardWeek : function(b, c, a) {
  8794. b = Ext.Date.clearTime(new Date(b));
  8795. c = Ext.Date.clearTime(new Date(c));
  8796. if (this.intersectsWithCurrentWeeks(b, c)) {
  8797. throw new Error("Can not add intersecting week")
  8798. }
  8799. Ext.Array.each(a, function(d, e) {
  8800. if (d) {
  8801. d.set(d.idProperty, e + "-"
  8802. + Ext.Date.format(b, "Y/m/d") + "-"
  8803. + Ext.Date.format(c, "Y/m/d"))
  8804. }
  8805. });
  8806. b = b - 0;
  8807. c = c - 0;
  8808. this.nonStandardWeeksStartDates.push(b);
  8809. this.nonStandardWeeksStartDates.sort();
  8810. this.nonStandardWeeksByStartDate[b] = {
  8811. startDate : new Date(b),
  8812. endDate : new Date(c),
  8813. weekAvailability : a
  8814. };
  8815. this.add(Ext.Array.clean(a))
  8816. },
  8817. getNonStandardWeekByStartDate : function(a) {
  8818. return this.nonStandardWeeksByStartDate[Ext.Date.clearTime(new Date(a))
  8819. - 0]
  8820. },
  8821. getNonStandardWeekByDate : function(d) {
  8822. d = Ext.Date.clearTime(new Date(d)) - 0;
  8823. var e = this.nonStandardWeeksStartDates;
  8824. var a = this.nonStandardWeeksByStartDate;
  8825. for (var c = 0; c < e.length; c++) {
  8826. var b = a[e[c]];
  8827. if (b.startDate <= d && d <= b.endDate) {
  8828. return b
  8829. }
  8830. }
  8831. return null
  8832. },
  8833. removeNonStandardWeek : function(a) {
  8834. a = Ext.Date.clearTime(new Date(a)) - 0;
  8835. var b = this.getNonStandardWeekByStartDate(a);
  8836. if (!b) {
  8837. return
  8838. }
  8839. this.remove(Ext.Array.clean(b.weekAvailability));
  8840. delete this.nonStandardWeeksByStartDate[a];
  8841. Ext.Array.remove(this.nonStandardWeeksStartDates, a)
  8842. },
  8843. clearCache : function() {
  8844. this.holidaysCache = {};
  8845. this.availabilityIntervalsCache = {};
  8846. this.fireEvent("clearcache", this)
  8847. },
  8848. setWeekendsAreWorkDays : function(a) {
  8849. if (a !== this.weekendsAreWorkdays) {
  8850. this.weekendsAreWorkdays = a;
  8851. this.clearCache();
  8852. this.defaultWeekAvailability = this
  8853. .getDefaultWeekAvailability(this.weekendsAreWorkdays)
  8854. }
  8855. },
  8856. areWeekendsWorkDays : function() {
  8857. return this.weekendsAreWorkdays
  8858. },
  8859. getCalendarDay : function(b) {
  8860. b = typeof b == "number" ? new Date(b) : b;
  8861. var a = this.getOverrideDay(b);
  8862. if (a) {
  8863. return a
  8864. }
  8865. return this.getDefaultCalendarDay(b.getDay(), b)
  8866. },
  8867. getOverrideDay : function(a) {
  8868. var b = this.getOwnCalendarDay(a);
  8869. if (b) {
  8870. return b
  8871. }
  8872. if (this.parent) {
  8873. return this.parent.getOverrideDay(a)
  8874. }
  8875. return null
  8876. },
  8877. getOwnCalendarDay : function(a) {
  8878. a = typeof a == "number" ? new Date(a) : a;
  8879. return this.getById(Ext.Date.clearTime(a, true) - 0)
  8880. },
  8881. getDefaultCalendarDay : function(c, b) {
  8882. if (b) {
  8883. var a = this.getNonStandardWeekByDate(b);
  8884. if (a && a.weekAvailability[c]) {
  8885. return a.weekAvailability[c]
  8886. }
  8887. }
  8888. if (this.weekAvailability[c]) {
  8889. return this.weekAvailability[c]
  8890. }
  8891. if (this.parent) {
  8892. return this.parent.getDefaultCalendarDay(c)
  8893. }
  8894. return this.defaultWeekAvailability[c]
  8895. },
  8896. isHoliday : function(c) {
  8897. var b = c - 0;
  8898. var d = this.holidaysCache;
  8899. if (d[b] != null) {
  8900. return d[b]
  8901. }
  8902. c = typeof c == "number" ? new Date(c) : c;
  8903. var a = this.getCalendarDay(c);
  8904. if (!a) {
  8905. throw "Can't find day for " + c
  8906. }
  8907. return d[b] = !a.getIsWorkingDay()
  8908. },
  8909. isWeekend : function(b) {
  8910. var a = b.getDay();
  8911. return a === this.weekendFirstDay || a === this.weekendSecondDay
  8912. },
  8913. isWorkingDay : function(a) {
  8914. return !this.isHoliday(a)
  8915. },
  8916. convertMSDurationToUnit : function(a, b) {
  8917. return a / this.unitsInMs[Sch.util.Date.getNameOfUnit(b)]
  8918. },
  8919. convertDurationToMs : function(b, a) {
  8920. return b * this.unitsInMs[Sch.util.Date.getNameOfUnit(a)]
  8921. },
  8922. getHolidaysRanges : function(d, g, a) {
  8923. if (d > g) {
  8924. Ext.Error.raise("startDate can't be bigger than endDate")
  8925. }
  8926. d = Ext.Date.clearTime(d, true);
  8927. g = Ext.Date.clearTime(g, true);
  8928. var c = [], h, e;
  8929. for (e = d; e < g; e = Sch.util.Date.getNext(e, Sch.util.Date.DAY, 1)) {
  8930. if (this.isHoliday(e)
  8931. || (this.weekendsAreWorkdays && a && this.isWeekend(e))) {
  8932. var i = this.getCalendarDay(e);
  8933. var j = i && i.getCls() || this.defaultNonWorkingTimeCssCls;
  8934. var f = Sch.util.Date.getNext(e, Sch.util.Date.DAY, 1);
  8935. if (!h) {
  8936. h = {
  8937. StartDate : e,
  8938. EndDate : f,
  8939. Cls : j
  8940. }
  8941. } else {
  8942. if (h.Cls == j) {
  8943. h.EndDate = f
  8944. } else {
  8945. c.push(h);
  8946. h = {
  8947. StartDate : e,
  8948. EndDate : f,
  8949. Cls : j
  8950. }
  8951. }
  8952. }
  8953. } else {
  8954. if (h) {
  8955. c.push(h);
  8956. h = null
  8957. }
  8958. }
  8959. }
  8960. if (h) {
  8961. c.push(h)
  8962. }
  8963. var b = [];
  8964. Ext.each(c, function(k) {
  8965. b.push(Ext.create("Sch.model.Range", {
  8966. StartDate : k.StartDate,
  8967. EndDate : k.EndDate,
  8968. Cls : k.Cls
  8969. }))
  8970. });
  8971. return b
  8972. },
  8973. forEachAvailabilityInterval : function(r, f, p) {
  8974. p = p || this;
  8975. var l = this;
  8976. var d = r.startDate;
  8977. var j = r.endDate;
  8978. var o = r.isForward !== false;
  8979. if (o ? !d : !j) {
  8980. throw new Error("At least `startDate` or `endDate` is required, depending from the `isForward` option")
  8981. }
  8982. var a = new Date(o ? d : j);
  8983. var q = o ? !j : !d;
  8984. var c = Sch.util.Date;
  8985. while (q || (o ? a < j : a > d)) {
  8986. var h = this.getAvailabilityIntervalsFor(a - (o ? 0 : 1));
  8987. for (var g = o ? 0 : h.length - 1; o ? g < h.length : g >= 0; o
  8988. ? g++
  8989. : g--) {
  8990. var b = h[g];
  8991. var k = b.startDate;
  8992. var n = b.endDate;
  8993. if (k >= j || n <= d) {
  8994. continue
  8995. }
  8996. var e = k < d ? d : k;
  8997. var m = n > j ? j : n;
  8998. if (f.call(p, e, m) === false) {
  8999. return false
  9000. }
  9001. }
  9002. a = o ? c.getStartOfNextDay(a) : c.getEndOfPreviousDay(a)
  9003. }
  9004. },
  9005. calculateDuration : function(a, d, b) {
  9006. var c = 0;
  9007. this.forEachAvailabilityInterval({
  9008. startDate : a,
  9009. endDate : d
  9010. }, function(g, f) {
  9011. var e = g.getTimezoneOffset() - f.getTimezoneOffset();
  9012. c += f - g + e * 60 * 1000
  9013. });
  9014. return this.convertMSDurationToUnit(c, b)
  9015. },
  9016. calculateEndDate : function(a, f, b) {
  9017. if (!f) {
  9018. return new Date(a)
  9019. }
  9020. var e = Sch.util.Date, d;
  9021. f = this.convertDurationToMs(f, b);
  9022. var c = f === 0 && Ext.Date.clearTime(a, true) - a === 0 ? e.add(a,
  9023. Sch.util.Date.DAY, -1) : a;
  9024. this.forEachAvailabilityInterval({
  9025. startDate : c
  9026. }, function(i, h) {
  9027. var j = h - i;
  9028. var g = i.getTimezoneOffset() - h.getTimezoneOffset();
  9029. if (j >= f) {
  9030. d = new Date(i - 0 + f);
  9031. return false
  9032. } else {
  9033. f -= j + g * 60 * 1000
  9034. }
  9035. });
  9036. return d
  9037. },
  9038. calculateStartDate : function(d, c, b) {
  9039. if (!c) {
  9040. return new Date(d)
  9041. }
  9042. var a;
  9043. c = this.convertDurationToMs(c, b);
  9044. this.forEachAvailabilityInterval({
  9045. endDate : d,
  9046. isForward : false
  9047. }, function(f, e) {
  9048. var g = e - f;
  9049. if (g >= c) {
  9050. a = new Date(e - c);
  9051. return false
  9052. } else {
  9053. c -= g
  9054. }
  9055. });
  9056. return a
  9057. },
  9058. skipNonWorkingTime : function(a, b) {
  9059. this.forEachAvailabilityInterval(b ? {
  9060. startDate : a
  9061. } : {
  9062. endDate : a,
  9063. isForward : false
  9064. }, function(d, c) {
  9065. a = b ? d : c;
  9066. return false
  9067. });
  9068. return new Date(a)
  9069. },
  9070. skipWorkingTime : function(a, c, b) {
  9071. return c >= 0 ? this.calculateEndDate(a, c, b) : this
  9072. .calculateStartDate(a, -c, b)
  9073. },
  9074. getAvailabilityIntervalsFor : function(a) {
  9075. a = Ext.Date.clearTime(new Date(a)) - 0;
  9076. if (this.availabilityIntervalsCache[a]) {
  9077. return this.availabilityIntervalsCache[a]
  9078. }
  9079. return this.availabilityIntervalsCache[a] = this.getCalendarDay(a)
  9080. .getAvailabilityIntervalsFor(a)
  9081. },
  9082. getParentableCalendars : function() {
  9083. var c = this, a = [], d = Gnt.data.Calendar.getAllCalendars();
  9084. var b = function(e) {
  9085. if (!e.parent) {
  9086. return false
  9087. }
  9088. if (e.parent == c) {
  9089. return true
  9090. }
  9091. return b(e.parent)
  9092. };
  9093. Ext.Array.each(d, function(e) {
  9094. if (e === c) {
  9095. return
  9096. }
  9097. if (!b(e)) {
  9098. a.push({
  9099. Id : e.calendarId,
  9100. Name : e.name || e.calendarId
  9101. })
  9102. }
  9103. });
  9104. return a
  9105. }
  9106. });
  9107. Ext.define("Gnt.data.calendar.BusinessTime", {
  9108. extend : "Gnt.data.Calendar",
  9109. daysPerMonth : 20,
  9110. daysPerWeek : 5,
  9111. hoursPerDay : 8,
  9112. defaultAvailability : ["08:00-12:00", "13:00-17:00"]
  9113. });
  9114. Ext.define("Gnt.data.TaskStore", {
  9115. extend : "Ext.data.TreeStore",
  9116. requires : ["Sch.patches.TreeStore", "Gnt.model.Task", "Gnt.data.Calendar"],
  9117. mixins : ["Sch.data.mixin.BufferableTreeStore",
  9118. "Sch.data.mixin.FilterableTreeStore", "Sch.data.mixin.EventStore"],
  9119. model : "Gnt.model.Task",
  9120. calendar : null,
  9121. dependencyStore : null,
  9122. resourceStore : null,
  9123. assignmentStore : null,
  9124. weekendsAreWorkdays : false,
  9125. buffered : false,
  9126. pageSize : null,
  9127. cascadeChanges : false,
  9128. batchSync : true,
  9129. recalculateParents : true,
  9130. skipWeekendsDuringDragDrop : true,
  9131. cascadeDelay : 0,
  9132. cascading : false,
  9133. isFillingRoot : false,
  9134. constructor : function(c) {
  9135. this.addEvents("root-fill-start", "root-fill-end", "filter",
  9136. "clearfilter", "beforecascade", "cascade");
  9137. c = c || {};
  9138. if (!c.calendar) {
  9139. var a = {};
  9140. if (c.hasOwnProperty("weekendsAreWorkdays")) {
  9141. a.weekendsAreWorkdays = c.weekendsAreWorkdays
  9142. } else {
  9143. if (this.self.prototype.hasOwnProperty("weekendsAreWorkdays")
  9144. && this.self != Gnt.data.TaskStore) {
  9145. a.weekendsAreWorkdays = this.weekendsAreWorkdays
  9146. }
  9147. }
  9148. c.calendar = new Gnt.data.Calendar(a)
  9149. }
  9150. this.hasListeners = {};
  9151. this.on({
  9152. "root-fill-end" : this.onRootFillEnd,
  9153. remove : this.onTaskDeleted,
  9154. beforesync : this.onTaskStoreBeforeSync,
  9155. write : this.onTaskStoreWrite,
  9156. scope : this
  9157. });
  9158. var b = c.dependencyStore;
  9159. if (b) {
  9160. delete c.dependencyStore;
  9161. this.setDependencyStore(b)
  9162. }
  9163. var d = c.resourceStore;
  9164. if (d) {
  9165. delete c.resourceStore;
  9166. this.setResourceStore(d)
  9167. }
  9168. var f = c.assignmentStore;
  9169. if (f) {
  9170. delete c.assignmentStore;
  9171. this.setAssignmentStore(f)
  9172. }
  9173. var e = c.calendar;
  9174. if (e) {
  9175. delete c.calendar;
  9176. this.setCalendar(e)
  9177. }
  9178. this.callParent([c]);
  9179. if (Ext.data.reader.Xml
  9180. && this.getProxy().getReader() instanceof Ext.data.reader.Xml) {
  9181. Ext.override(this.getProxy().getReader(), {
  9182. extractData : function(g) {
  9183. var h = this.record;
  9184. if (h != g.nodeName) {
  9185. g = Ext.DomQuery.select(">" + h, g)
  9186. } else {
  9187. g = [g]
  9188. }
  9189. return Ext.data.reader.Xml.superclass.extractData
  9190. .apply(this, [g])
  9191. }
  9192. })
  9193. }
  9194. if (this.autoSync && this.batchSync) {
  9195. this.sync = Ext.Function.createBuffered(this.sync, 500)
  9196. }
  9197. this.initTreeFiltering();
  9198. this.initTreeBuffering()
  9199. },
  9200. load : function() {
  9201. this.un("remove", this.onTaskDeleted, this);
  9202. this.callParent(arguments);
  9203. this.on("remove", this.onTaskDeleted, this)
  9204. },
  9205. loadData : function(B, w) {
  9206. var z = this, r = z.getRootNode(), c = w ? w.addRecords : false, t = w
  9207. ? w.syncStore
  9208. : false;
  9209. z.suspendAutoSync();
  9210. z.suspendEvents();
  9211. if (!c && r) {
  9212. r.removeAll()
  9213. }
  9214. if (!z.getRootNode()) {
  9215. r = z.setRootNode()
  9216. }
  9217. if (!B.length) {
  9218. return
  9219. } else {
  9220. var f = B.length, e = z.model, n = [], u = (typeof B[0].get === "function"), b, p, o, x, y, A, v, m, h;
  9221. for (var s = 0; s < f; s++) {
  9222. p = z.getById(B[s].getId ? B[s].getId() : B[s].Id);
  9223. b = 0;
  9224. if (p) {
  9225. x = u ? B[s].get("parentId") : B[s].parentId;
  9226. y = p.get("parentId");
  9227. A = u ? B[s].get("index") : B[s].index;
  9228. v = p.get("index");
  9229. if (u) {
  9230. p.set(B[s].data)
  9231. } else {
  9232. p.set(B[s])
  9233. }
  9234. if (((x || x === null) ? (x !== y) : false)
  9235. || (A ? (A !== v) : false)) {
  9236. m = x === null ? r : z.getById(x);
  9237. h = y === null ? r : z.getById(y)
  9238. } else {
  9239. b = 1
  9240. }
  9241. } else {
  9242. p = u ? new e(B[s].data) : new e(B[s]);
  9243. y = p.get("parentId");
  9244. if (y) {
  9245. m = z.getById(y)
  9246. } else {
  9247. if (y === null) {
  9248. m = r
  9249. }
  9250. }
  9251. }
  9252. if (m && !b) {
  9253. z.moveChildren(p, m, h)
  9254. } else {
  9255. if (typeof m === "undefined" && !b) {
  9256. o = {
  9257. node : p,
  9258. index : p.get("index") || 0,
  9259. parentId : p.get("parentId")
  9260. };
  9261. n.push(o)
  9262. }
  9263. }
  9264. if (m && !t) {
  9265. m.commit();
  9266. p.commit();
  9267. if (h) {
  9268. h.commit()
  9269. }
  9270. }
  9271. }
  9272. var g = 0, j = n.length, d, k;
  9273. if (n.length) {
  9274. z.sortNewNodesByIndex(n)
  9275. }
  9276. while (n.length) {
  9277. if (g > n.length - 1) {
  9278. g = 0
  9279. }
  9280. d = n[g];
  9281. k = d.parentId === null ? r : z.getById(d.parentId);
  9282. if (k) {
  9283. var a = z.nodeIsChild(d.node, m);
  9284. if (a) {
  9285. k.insertChild(d.index, d.node);
  9286. z.fixNodeDates(d.node);
  9287. n.splice(g, 1);
  9288. if (!t) {
  9289. k.commit();
  9290. d.node.commit()
  9291. }
  9292. g -= 1
  9293. }
  9294. }
  9295. g += 1;
  9296. if (g === j - 1 && n.length === j) {
  9297. throw "Invalid data, possible infinite loop."
  9298. }
  9299. }
  9300. if (z.nodesToExpand) {
  9301. s = 0;
  9302. for (var q = z.nodesToExpand.length; s < q; s += 1) {
  9303. p = z.nodesToExpand[s];
  9304. if (p.childNodes && p.childNodes.length) {
  9305. p.expand()
  9306. }
  9307. }
  9308. delete z.nodesToExpand
  9309. }
  9310. }
  9311. z.resumeAutoSync();
  9312. z.resumeEvents();
  9313. this.fireEvent("datachanged");
  9314. this.fireEvent("refresh");
  9315. if (t) {
  9316. z.sync()
  9317. }
  9318. },
  9319. sortNewNodesByIndex : function(a) {
  9320. Ext.Array.sort(a, function(b, e) {
  9321. var d = b.index, c = e.index;
  9322. if (d && c) {
  9323. if (d < c) {
  9324. return -1
  9325. } else {
  9326. if (d > c) {
  9327. return 1
  9328. } else {
  9329. return 0
  9330. }
  9331. }
  9332. }
  9333. return 0
  9334. })
  9335. },
  9336. fixNodeDates : function(b) {
  9337. var c = b.calculateDuration(b.getStartDate(), b.getEndDate(), b
  9338. .getDurationUnit()), a;
  9339. b.set({
  9340. Duration : c
  9341. });
  9342. if (this.recalculateParents) {
  9343. if (b.childNodes.length) {
  9344. a = b.getChildAt(0);
  9345. a.recalculateParents()
  9346. } else {
  9347. b.recalculateParents()
  9348. }
  9349. }
  9350. },
  9351. nodeIsChild : function(c, b) {
  9352. var d = b.getId(), a = true;
  9353. if (c.childNodes.length) {
  9354. c.cascadeBy(function(e) {
  9355. if (e.getId() === d) {
  9356. a = false;
  9357. return false
  9358. }
  9359. })
  9360. }
  9361. return a
  9362. },
  9363. moveChildren : function(e, d, c) {
  9364. if (e.get("expanded")) {
  9365. if (!this.nodesToExpand) {
  9366. this.nodesToExpand = []
  9367. }
  9368. this.nodesToExpand.push(e);
  9369. e.set("expanded", false)
  9370. }
  9371. var b, f = this.nodeIsChild(e, d), a = c
  9372. || this.getById(e.get("parentId"));
  9373. if (f) {
  9374. if (e.childNodes.length) {
  9375. b = e.copy(null, true);
  9376. e.removeAll()
  9377. }
  9378. if (a && a.getId() !== d.getId()) {
  9379. a.removeChild(e)
  9380. }
  9381. e.get("index") ? d.insertChild(e.get("index"), e) : d
  9382. .appendChild(e);
  9383. if (b) {
  9384. b.cascadeBy(function(h) {
  9385. if (h !== b) {
  9386. var g = h.copy(null);
  9387. g.get("index") ? e.insertChild(g.get("index"),
  9388. g) : e.appendChild(g)
  9389. }
  9390. })
  9391. }
  9392. this.fixNodeDates(e)
  9393. }
  9394. },
  9395. onNodeAdded : function(c, e) {
  9396. if (!e.normalized && !e.isRoot()) {
  9397. e.normalize()
  9398. }
  9399. if (Ext.isIE) {
  9400. var d = this, b = d.getProxy(), a = b.getReader(), f = e.raw
  9401. || e[e.persistenceProperty], g;
  9402. Ext.Array.remove(d.removed, e);
  9403. if (!e.isLeaf()) {
  9404. g = a.getRoot(f);
  9405. if (g) {
  9406. d.fillNode(e, a.extractData(g));
  9407. if (f[a.root]) {
  9408. delete f[a.root]
  9409. }
  9410. }
  9411. }
  9412. if (d.autoSync && !d.autoSyncSuspended && (e.phantom || e.dirty)) {
  9413. d.sync()
  9414. }
  9415. } else {
  9416. this.callParent(arguments)
  9417. }
  9418. },
  9419. setRootNode : function() {
  9420. var b = this;
  9421. this.tree.setRootNode = Ext.Function.createInterceptor(
  9422. this.tree.setRootNode, function(c) {
  9423. Ext.apply(c, {
  9424. calendar : b.calendar,
  9425. taskStore : b,
  9426. dependencyStore : b.dependencyStore,
  9427. phantom : false,
  9428. dirty : false
  9429. })
  9430. });
  9431. var a = this.callParent(arguments);
  9432. delete this.tree.setRootNode;
  9433. return a
  9434. },
  9435. fillNode : function(g, c) {
  9436. this.isFillingNode = true;
  9437. if (g.isRoot()) {
  9438. this.isFillingRoot = true;
  9439. this.un({
  9440. remove : this.onNodeUpdated,
  9441. append : this.onNodeUpdated,
  9442. insert : this.onNodeUpdated,
  9443. update : this.onTaskUpdated,
  9444. scope : this
  9445. });
  9446. this.fireEvent("root-fill-start", this, g, c)
  9447. }
  9448. var f = this, e = c ? c.length : 0, d = 0, b;
  9449. if (e && f.sortOnLoad && !f.remoteSort && f.sorters && f.sorters.items) {
  9450. b = Ext.create("Ext.util.MixedCollection");
  9451. b.addAll(c);
  9452. b.sort(f.sorters.items);
  9453. c = b.items
  9454. }
  9455. g.set("loaded", true);
  9456. if (this.buffered) {
  9457. for (; d < e; d++) {
  9458. var a = c[d];
  9459. a.__isFilling__ = true;
  9460. g.appendChild(a, true, true);
  9461. this.onNodeAdded(null, a);
  9462. this.tree.registerNode(a)
  9463. }
  9464. } else {
  9465. for (; d < e; d++) {
  9466. c[d].__isFilling__ = true;
  9467. g.appendChild(c[d], false, true)
  9468. }
  9469. }
  9470. if (g.isRoot()) {
  9471. this.getRootNode().cascadeBy(function(h) {
  9472. delete h.__isFilling__
  9473. });
  9474. this.isFillingRoot = false;
  9475. this.on({
  9476. remove : this.onNodeUpdated,
  9477. append : this.onNodeUpdated,
  9478. insert : this.onNodeUpdated,
  9479. update : this.onTaskUpdated,
  9480. scope : this
  9481. });
  9482. this.fireEvent("root-fill-end", this, g, c)
  9483. }
  9484. delete this.isFillingNode;
  9485. return c
  9486. },
  9487. onRootFillEnd : function(b, a) {
  9488. a.normalizeEffort()
  9489. },
  9490. getById : function(a) {
  9491. return this.tree.getNodeById(a)
  9492. },
  9493. setDependencyStore : function(a) {
  9494. if (this.dependencyStore) {
  9495. this.dependencyStore.un({
  9496. add : this.onDependencyAddOrUpdate,
  9497. update : this.onDependencyAddOrUpdate,
  9498. scope : this
  9499. })
  9500. }
  9501. this.dependencyStore = Ext.StoreMgr.lookup(a);
  9502. if (a) {
  9503. a.taskStore = this;
  9504. a.on({
  9505. add : this.onDependencyAddOrUpdate,
  9506. update : this.onDependencyAddOrUpdate,
  9507. scope : this
  9508. })
  9509. }
  9510. },
  9511. setResourceStore : function(a) {
  9512. this.resourceStore = Ext.StoreMgr.lookup(a);
  9513. a.taskStore = this
  9514. },
  9515. getResourceStore : function() {
  9516. return this.resourceStore || null
  9517. },
  9518. setAssignmentStore : function(a) {
  9519. if (this.assignmentStore) {
  9520. this.assignmentStore.un({
  9521. add : this.onAssignmentStructureMutation,
  9522. update : this.onAssignmentMutation,
  9523. remove : this.onAssignmentStructureMutation,
  9524. scope : this
  9525. })
  9526. }
  9527. this.assignmentStore = Ext.StoreMgr.lookup(a);
  9528. a.taskStore = this;
  9529. a.on({
  9530. add : this.onAssignmentStructureMutation,
  9531. update : this.onAssignmentMutation,
  9532. remove : this.onAssignmentStructureMutation,
  9533. scope : this
  9534. })
  9535. },
  9536. getAssignmentStore : function() {
  9537. return this.assignmentStore || null
  9538. },
  9539. renormalizeTasks : function(b, a) {
  9540. if (a instanceof Gnt.model.Task) {
  9541. a.adjustToCalendar()
  9542. } else {
  9543. this.getRootNode().cascadeBy(function(c) {
  9544. c.adjustToCalendar()
  9545. })
  9546. }
  9547. },
  9548. getCalendar : function() {
  9549. return this.calendar || null
  9550. },
  9551. setCalendar : function(c) {
  9552. var b = {
  9553. datachanged : this.renormalizeTasks,
  9554. update : this.renormalizeTasks,
  9555. clear : this.renormalizeTasks,
  9556. scope : this
  9557. };
  9558. if (this.calendar) {
  9559. this.calendar.un(b)
  9560. }
  9561. this.calendar = c;
  9562. c.on(b);
  9563. var a = this.tree && this.getRootNode();
  9564. if (a) {
  9565. a.calendar = c
  9566. }
  9567. },
  9568. filter : function() {
  9569. this.fireEvent("filter", this, arguments)
  9570. },
  9571. clearFilter : function() {
  9572. this.fireEvent("clearfilter", this)
  9573. },
  9574. getCriticalPaths : function() {
  9575. var b = this.getRootNode(), a = [], d = new Date(0);
  9576. b.cascadeBy(function(e) {
  9577. d = Sch.util.Date.max(e.getEndDate(), d)
  9578. });
  9579. b.cascadeBy(function(e) {
  9580. if (d - e.getEndDate() === 0 && !e.isRoot()) {
  9581. a.push(e)
  9582. }
  9583. });
  9584. var c = [];
  9585. Ext.each(a, function(e) {
  9586. c.push(e.getCriticalPaths())
  9587. });
  9588. return c
  9589. },
  9590. onNodeUpdated : function(a, b) {
  9591. if (!this.cascading && this.recalculateParents && !this.isFillingNode) {
  9592. b.recalculateParents()
  9593. }
  9594. },
  9595. onTaskUpdated : function(c, b, a) {
  9596. var d = b.previous;
  9597. if (!this.cascading
  9598. && !this.isFillingNode
  9599. && a !== Ext.data.Model.COMMIT
  9600. && (d && (b.startDateField in d || b.endDateField in d
  9601. || "parentId" in d || b.effortField in d))) {
  9602. if (this.cascadeChanges) {
  9603. Ext.Function.defer(this.cascadeChangesForTask,
  9604. this.cascadeDelay, this, [b])
  9605. }
  9606. if (this.recalculateParents) {
  9607. b.recalculateParents()
  9608. }
  9609. }
  9610. },
  9611. cascadeChangesForTask : function(a) {
  9612. var c = this, b = {
  9613. nbrAffected : 0
  9614. };
  9615. Ext.each(a.getOutgoingDependencies(), function(d) {
  9616. var e = d.getTargetTask();
  9617. if (e) {
  9618. if (!c.cascading) {
  9619. c.fireEvent("beforecascade", c)
  9620. }
  9621. c.cascading = true;
  9622. e.cascadeChanges(c, b, d)
  9623. }
  9624. });
  9625. if (c.cascading) {
  9626. c.cascading = false;
  9627. c.fireEvent("cascade", c, b)
  9628. }
  9629. },
  9630. onTaskDeleted : function(c, b) {
  9631. var a = this.dependencyStore;
  9632. if (a && !b.isReplace && !b.isMove) {
  9633. a.remove(b.getAllDependencies(a))
  9634. }
  9635. },
  9636. onAssignmentMutation : function(c, a) {
  9637. var b = this;
  9638. Ext.each(a, function(e) {
  9639. var d = e.getTask(b);
  9640. if (d) {
  9641. d.onAssignmentMutation(e)
  9642. }
  9643. })
  9644. },
  9645. onAssignmentStructureMutation : function(c, a) {
  9646. var b = this;
  9647. Ext.each(a, function(d) {
  9648. d.getTask(b).onAssignmentStructureMutation(d)
  9649. })
  9650. },
  9651. onDependencyAddOrUpdate : function(b, d) {
  9652. if (this.cascadeChanges) {
  9653. var c = this, a;
  9654. Ext.each(d, function(e) {
  9655. a = e.getTargetTask();
  9656. if (a) {
  9657. a.constrain(c)
  9658. }
  9659. })
  9660. }
  9661. },
  9662. getNewRecords : function() {
  9663. return Ext.Array.filter(this.tree.flatten(), this.filterNew, this)
  9664. },
  9665. getUpdatedRecords : function() {
  9666. return Ext.Array.filter(this.tree.flatten(), this.filterUpdated, this)
  9667. },
  9668. filterNew : function(a) {
  9669. return a.phantom && a.isValid() && a != this.tree.root
  9670. },
  9671. filterUpdated : function(a) {
  9672. return a.dirty && !a.phantom && a.isValid() && a != this.tree.root
  9673. },
  9674. onTaskStoreBeforeSync : function(b, c) {
  9675. var a = b.create;
  9676. if (a) {
  9677. for (var e, d = a.length - 1; d >= 0; d--) {
  9678. e = a[d];
  9679. if (e.isPersistable()) {
  9680. e._phantomId = e.internalId
  9681. } else {
  9682. if (this.autoSync) {
  9683. Ext.Array.remove(a, e)
  9684. }
  9685. }
  9686. }
  9687. if (a.length === 0) {
  9688. delete b.create
  9689. }
  9690. }
  9691. return Boolean((b.create && b.create.length > 0)
  9692. || (b.update && b.update.length > 0)
  9693. || (b.destroy && b.destroy.length > 0))
  9694. },
  9695. onTaskStoreWrite : function(c, b) {
  9696. var d = this.dependencyStore;
  9697. if (!d || b.action !== "create") {
  9698. return
  9699. }
  9700. var a = b.getRecords(), e;
  9701. Ext.each(a, function(f) {
  9702. e = f.getId();
  9703. if (!f.phantom && e !== f._phantomId) {
  9704. Ext.each(d.getNewRecords(), function(g) {
  9705. var i = g.getSourceId();
  9706. var h = g.getTargetId();
  9707. if (i === f._phantomId) {
  9708. g.setSourceId(e)
  9709. } else {
  9710. if (h === f._phantomId) {
  9711. g.setTargetId(e)
  9712. }
  9713. }
  9714. });
  9715. Ext.each(f.childNodes, function(g) {
  9716. if (g.phantom) {
  9717. g.set("parentId", e)
  9718. }
  9719. });
  9720. delete f._phantomId
  9721. }
  9722. })
  9723. },
  9724. getTotalTimeSpan : function() {
  9725. var a = new Date(9999, 0, 1), b = new Date(0), c = Sch.util.Date;
  9726. this.getRootNode().cascadeBy(function(d) {
  9727. if (d.getStartDate()) {
  9728. a = c.min(d.getStartDate(), a)
  9729. }
  9730. if (d.getEndDate()) {
  9731. b = c.max(d.getEndDate(), b)
  9732. }
  9733. });
  9734. a = a < new Date(9999, 0, 1) ? a : null;
  9735. b = b > new Date(0) ? b : null;
  9736. return {
  9737. start : a,
  9738. end : b || a || null
  9739. }
  9740. },
  9741. getCount : function(b) {
  9742. var a = b === false ? 0 : -1;
  9743. this.getRootNode().cascadeBy(function() {
  9744. a++
  9745. });
  9746. return a
  9747. },
  9748. toArray : function() {
  9749. var a = [];
  9750. this.getRootNode().cascadeBy(function(b) {
  9751. a.push(b)
  9752. });
  9753. return a
  9754. },
  9755. remove : function(a) {
  9756. Ext.each(a, function(b) {
  9757. b.remove()
  9758. })
  9759. },
  9760. indent : function(b) {
  9761. b = Ext.isArray(b) ? b : [b];
  9762. var a = Ext.Array.sort(b, function(d, c) {
  9763. return d.data.index > c.data.index
  9764. });
  9765. Ext.each(a, function(c) {
  9766. c.indent()
  9767. })
  9768. },
  9769. outdent : function(b) {
  9770. var a = Ext.Array.sort(b, function(d, c) {
  9771. return d.data.index > c.data.index
  9772. });
  9773. Ext.each(a, function(c) {
  9774. c.indent()
  9775. });
  9776. Ext.each(b, function(c) {
  9777. c.outdent()
  9778. })
  9779. },
  9780. getTasksForResource : function(a) {
  9781. return a.getTasks()
  9782. },
  9783. getEventsForResource : function(a) {
  9784. return this.getTasksForResource(a)
  9785. },
  9786. ensureSingleSyncForMethod : function() {
  9787. return function() {
  9788. var b;
  9789. if (this.autoSync && !this.autoSyncSuspended) {
  9790. b = true;
  9791. this.suspendAutoSync()
  9792. }
  9793. var a = this.callParent(arguments);
  9794. if (b) {
  9795. this.resumeAutoSync();
  9796. this.sync()
  9797. }
  9798. return a
  9799. }
  9800. },
  9801. indexOf : function(a) {
  9802. return a && this.tree.getNodeById(a.internalId) ? 0 : -1
  9803. },
  9804. getByInternalId : function(a) {
  9805. return this.tree.getNodeById(a)
  9806. }
  9807. }, function() {
  9808. var a = ["indent", "outdent", "afterEdit", "remove"];
  9809. Ext.each(a, function(c) {
  9810. var b = {};
  9811. b[c] = this.prototype
  9812. .ensureSingleSyncForMethod(this.prototype[c]);
  9813. this.override(b)
  9814. }, this)
  9815. });
  9816. Ext.define("Gnt.data.DependencyStore", {
  9817. extend : "Ext.data.Store",
  9818. model : "Gnt.model.Dependency",
  9819. constructor : function() {
  9820. this.callParent(arguments);
  9821. this.init()
  9822. },
  9823. init : function() {
  9824. this.on({
  9825. beforesync : this.onBeforeSyncOperation,
  9826. scope : this
  9827. })
  9828. },
  9829. onBeforeSyncOperation : function(a, b) {
  9830. if (a.create) {
  9831. for (var d, c = a.create.length - 1; c >= 0; c--) {
  9832. d = a.create[c];
  9833. if (!d.isPersistable()) {
  9834. Ext.Array.remove(a.create, d)
  9835. }
  9836. }
  9837. if (a.create.length === 0) {
  9838. delete a.create
  9839. }
  9840. }
  9841. return Boolean((a.create && a.create.length > 0)
  9842. || (a.update && a.update.length > 0)
  9843. || (a.destroy && a.destroy.length > 0))
  9844. },
  9845. getDependenciesForTask : function(b) {
  9846. var g = b.getId() || b.internalId;
  9847. var e = [], f = this;
  9848. for (var d = 0, a = f.getCount(); d < a; d++) {
  9849. var c = f.getAt(d);
  9850. if (c.getSourceId() == g || c.getTargetId() == g) {
  9851. e.push(c)
  9852. }
  9853. }
  9854. return e
  9855. },
  9856. getIncomingDependenciesForTask : function(b) {
  9857. var g = b.getId() || b.internalId;
  9858. var e = [], f = this;
  9859. for (var d = 0, a = f.getCount(); d < a; d++) {
  9860. var c = f.getAt(d);
  9861. if (c.getTargetId() == g) {
  9862. e.push(c)
  9863. }
  9864. }
  9865. return e
  9866. },
  9867. getOutgoingDependenciesForTask : function(b) {
  9868. var g = b.getId() || b.internalId;
  9869. var e = [], f = this;
  9870. for (var d = 0, a = f.getCount(); d < a; d++) {
  9871. var c = f.getAt(d);
  9872. if (c.getSourceId() == g) {
  9873. e.push(c)
  9874. }
  9875. }
  9876. return e
  9877. },
  9878. hasTransitiveDependency : function(d, b, a) {
  9879. var c = this;
  9880. return this.findBy(function(f) {
  9881. var e = f.getTargetId();
  9882. if (f.getSourceId() === d) {
  9883. return (e === b && f !== a) ? true : c
  9884. .hasTransitiveDependency(f
  9885. .getTargetId(), b, a)
  9886. }
  9887. }) >= 0
  9888. },
  9889. isValidDependency : function(h, b, e) {
  9890. var f = true;
  9891. var d, c, a;
  9892. if (h instanceof Gnt.model.Dependency) {
  9893. d = h.getSourceId();
  9894. c = this.getSourceTask(d);
  9895. b = h.getTargetId();
  9896. a = this.getTargetTask(b)
  9897. } else {
  9898. d = h;
  9899. c = this.getSourceTask(d);
  9900. a = this.getTargetTask(b)
  9901. }
  9902. if (!e && h instanceof Gnt.model.Dependency) {
  9903. f = h.isValid()
  9904. } else {
  9905. f = d && b && d !== b
  9906. }
  9907. if (f) {
  9908. if (c && a && (c.contains(a) || a.contains(c))) {
  9909. f = false
  9910. }
  9911. var g = e || (h instanceof Gnt.model.Dependency);
  9912. if (f
  9913. && ((!g && this.areTasksLinked(d, b)) || this
  9914. .hasTransitiveDependency(b, d, g ? h : null))) {
  9915. f = false
  9916. }
  9917. }
  9918. return f
  9919. },
  9920. areTasksLinked : function(c, e) {
  9921. var d = this;
  9922. var b = c instanceof Gnt.model.Task
  9923. ? (c.getId() || c.internalId)
  9924. : c;
  9925. var a = e instanceof Gnt.model.Task
  9926. ? (e.getId() || e.internalId)
  9927. : e;
  9928. return !!this.getByTaskIds(b, a)
  9929. },
  9930. getByTaskIds : function(c, b) {
  9931. var d = this;
  9932. var a = this.findBy(function(g) {
  9933. var e = g.getTargetId(), f = g.getSourceId();
  9934. if ((f === c && e === b) || (f === b && e === c)) {
  9935. return true
  9936. }
  9937. });
  9938. return this.getAt(a)
  9939. },
  9940. getSourceTask : function(a) {
  9941. var b = a instanceof Gnt.model.Dependency ? a.getSourceId() : a;
  9942. return this.getTaskStore().getById(b)
  9943. },
  9944. getTargetTask : function(a) {
  9945. var b = a instanceof Gnt.model.Dependency ? a.getTargetId() : a;
  9946. return this.getTaskStore().getById(b)
  9947. },
  9948. getTaskStore : function() {
  9949. return this.taskStore
  9950. }
  9951. });
  9952. Ext.define("Gnt.data.ResourceStore", {
  9953. requires : ["Gnt.model.Resource"],
  9954. extend : "Sch.data.ResourceStore",
  9955. model : "Gnt.model.Resource",
  9956. taskStore : null,
  9957. getTaskStore : function() {
  9958. return this.taskStore || null
  9959. },
  9960. getAssignmentStore : function() {
  9961. return this.assignmentStore || null
  9962. },
  9963. getByInternalId : function(a) {
  9964. return this.data.getByKey(a) || this.getById(a)
  9965. }
  9966. });
  9967. Ext.define("Gnt.data.AssignmentStore", {
  9968. requires : ["Gnt.model.Assignment"],
  9969. extend : "Ext.data.Store",
  9970. model : "Gnt.model.Assignment",
  9971. taskStore : null,
  9972. getTaskStore : function() {
  9973. return this.taskStore
  9974. },
  9975. getResourceStore : function() {
  9976. return this.getTaskStore().resourceStore
  9977. },
  9978. getByInternalId : function(a) {
  9979. return this.data.getByKey(a) || this.getById(a)
  9980. }
  9981. });
  9982. Ext.define("Gnt.template.Task", {
  9983. extend : "Ext.XTemplate",
  9984. constructor : function(a) {
  9985. this
  9986. .callParent([
  9987. '<div class="sch-event-wrap '
  9988. + a.baseCls
  9989. + ' x-unselectable" style="left:{leftOffset}px;">'
  9990. + (a.leftLabel
  9991. ? '<div class="sch-gantt-labelct sch-gantt-labelct-left"><label class="sch-gantt-label sch-gantt-label-left">{leftLabel}</label></div>'
  9992. : "")
  9993. + '<div id="'
  9994. + a.prefix
  9995. + '{id}" class="sch-gantt-item sch-gantt-task-bar {cls}" unselectable="on" style="width:{width}px;{style}">'
  9996. + (a.enableDependencyDragDrop
  9997. ? '<div unselectable="on" class="sch-gantt-terminal sch-gantt-terminal-start"></div>'
  9998. : "")
  9999. + ((a.resizeHandles === "both" || a.resizeHandles === "left")
  10000. ? '<div class="sch-resizable-handle sch-gantt-task-handle sch-resizable-handle-west"></div>'
  10001. : "")
  10002. + '<div class="sch-gantt-progress-bar" style="width:{percentDone}%;{progressBarStyle}" unselectable="on">&#160;</div>'
  10003. + ((a.resizeHandles === "both" || a.resizeHandles === "right")
  10004. ? '<div class="sch-resizable-handle sch-gantt-task-handle sch-resizable-handle-east"></div>'
  10005. : "")
  10006. + (a.enableDependencyDragDrop
  10007. ? '<div unselectable="on" class="sch-gantt-terminal sch-gantt-terminal-end"></div>'
  10008. : "")
  10009. + (a.enableProgressBarResize
  10010. ? '<div style="left:{percentDone}%" class="sch-gantt-progressbar-handle"></div>'
  10011. : "")
  10012. + "</div>"
  10013. + (a.rightLabel
  10014. ? '<div class="sch-gantt-labelct sch-gantt-labelct-right" style="left:{width}px"><label class="sch-gantt-label sch-gantt-label-right">{rightLabel}</label></div>'
  10015. : "") + "</div>", {
  10016. compiled : true,
  10017. disableFormats : true
  10018. }])
  10019. }
  10020. });
  10021. Ext.define("Gnt.template.Milestone", {
  10022. extend : "Ext.XTemplate",
  10023. constructor : function(a) {
  10024. this
  10025. .callParent([
  10026. '<div class="sch-event-wrap '
  10027. + a.baseCls
  10028. + ' x-unselectable" style="left:{leftOffset}px">'
  10029. + (a.leftLabel
  10030. ? '<div class="sch-gantt-labelct sch-gantt-labelct-left"><label class="sch-gantt-label sch-gantt-label-left">{leftLabel}</label></div>'
  10031. : "")
  10032. + (a.printable
  10033. ? ('<img id="' + a.prefix
  10034. + '{id}" src="' + a.imgSrc + '" class="sch-gantt-item sch-gantt-milestone-diamond {cls}" unselectable="on" style="{style}" />')
  10035. : ('<div id="'
  10036. + a.prefix
  10037. + '{id}" class="sch-gantt-item sch-gantt-milestone-diamond {cls}" unselectable="on" style="{style}">'
  10038. + (a.enableDependencyDragDrop
  10039. ? '<div class="sch-gantt-terminal sch-gantt-terminal-start"></div><div class="sch-gantt-terminal sch-gantt-terminal-end"></div>'
  10040. : "") + "</div>"))
  10041. + (a.rightLabel
  10042. ? '<div class="sch-gantt-labelct sch-gantt-labelct-right" style="left:{width}px"><label class="sch-gantt-label sch-gantt-label-right">{rightLabel}</label></div>'
  10043. : "") + "</div>", {
  10044. compiled : true,
  10045. disableFormats : true
  10046. }])
  10047. }
  10048. });
  10049. Ext.define("Gnt.template.ParentTask", {
  10050. extend : "Ext.XTemplate",
  10051. constructor : function(a) {
  10052. this
  10053. .callParent([
  10054. '<div class="sch-event-wrap '
  10055. + a.baseCls
  10056. + ' x-unselectable" style="left:{leftOffset}px;">'
  10057. + (a.leftLabel
  10058. ? '<div class="sch-gantt-labelct sch-gantt-labelct-left"><label class="sch-gantt-label sch-gantt-label-left">{leftLabel}</label></div>'
  10059. : "")
  10060. + '<div id="'
  10061. + a.prefix
  10062. + '{id}" class="sch-gantt-item sch-gantt-parenttask-bar {cls}" style="width:{width}px; {style}"><div class="sch-gantt-progress-bar" style="width:{percentDone}%;{progressBarStyle}">&#160;</div>'
  10063. + (a.enableDependencyDragDrop
  10064. ? '<div class="sch-gantt-terminal sch-gantt-terminal-start"></div>'
  10065. : "")
  10066. + '<div class="sch-gantt-parenttask-arrow sch-gantt-parenttask-leftarrow"></div><div class="sch-gantt-parenttask-arrow sch-gantt-parenttask-rightarrow"></div>'
  10067. + (a.enableDependencyDragDrop
  10068. ? '<div class="sch-gantt-terminal sch-gantt-terminal-end"></div>'
  10069. : "")
  10070. + "</div>"
  10071. + (a.rightLabel
  10072. ? '<div class="sch-gantt-labelct sch-gantt-labelct-right" style="left:{width}px"><label class="sch-gantt-label sch-gantt-label-right">{rightLabel}</label></div>'
  10073. : "") + "</div>", {
  10074. compiled : true,
  10075. disableFormats : true
  10076. }])
  10077. }
  10078. });
  10079. Ext.define("Gnt.Tooltip", {
  10080. extend : "Ext.ToolTip",
  10081. requires : ["Ext.Template"],
  10082. startText : "Starts: ",
  10083. endText : "Ends: ",
  10084. durationText : "Duration:",
  10085. mode : "startend",
  10086. cls : "sch-tip",
  10087. height : 40,
  10088. autoHide : false,
  10089. anchor : "b-tl",
  10090. maskOnDisable : false,
  10091. initComponent : function() {
  10092. if (this.mode === "startend" && !this.startEndTemplate) {
  10093. this.startEndTemplate = new Ext.Template('<div class="sch-timetipwrap {cls}"><div>'
  10094. + this.startText
  10095. + "{startText}</div><div>"
  10096. + this.endText
  10097. + "{endText}</div></div>").compile()
  10098. }
  10099. if (this.mode === "duration" && !this.durationTemplate) {
  10100. this.durationTemplate = new Ext.Template(
  10101. '<div class="sch-timetipwrap {cls}">', "<div>"
  10102. + this.startText + " {startText}</div>", "<div>"
  10103. + this.durationText + " {duration} {unit}</div>",
  10104. "</div>").compile()
  10105. }
  10106. this.callParent(arguments)
  10107. },
  10108. update : function(e, b, d, a) {
  10109. var c;
  10110. if (this.mode === "duration") {
  10111. c = this.getDurationContent(e, b, d, a)
  10112. } else {
  10113. c = this.getStartEndContent(e, b, d, a)
  10114. }
  10115. this.callParent([c])
  10116. },
  10117. getStartEndContent : function(b, f, a, h) {
  10118. var e = this.gantt, i = e.getFormattedDate(b), d = i, g;
  10119. if (f - b > 0) {
  10120. d = e.getFormattedEndDate(f, b)
  10121. }
  10122. var c = {
  10123. cls : a ? "sch-tip-ok" : "sch-tip-notok",
  10124. startText : i,
  10125. endText : d
  10126. };
  10127. if (this.showClock) {
  10128. Ext.apply(c, {
  10129. startHourDegrees : roundedStart.getHours() * 30,
  10130. startMinuteDegrees : roundedStart.getMinutes() * 6
  10131. });
  10132. if (f) {
  10133. Ext.apply(c, {
  10134. endHourDegrees : g.getHours() * 30,
  10135. endMinuteDegrees : g.getMinutes() * 6
  10136. })
  10137. }
  10138. }
  10139. return this.startEndTemplate.apply(c)
  10140. },
  10141. getDurationContent : function(f, b, d, a) {
  10142. var c = a.getDurationUnit() || Sch.util.Date.DAY;
  10143. var e = a.calculateDuration(f, b, c);
  10144. return this.durationTemplate.apply({
  10145. cls : d ? "sch-tip-ok" : "sch-tip-notok",
  10146. startText : this.gantt.getFormattedDate(f),
  10147. duration : parseFloat(Ext.Number.toFixed(e, 1)),
  10148. unit : Sch.util.Date.getReadableNameOfUnit(c, e > 1)
  10149. })
  10150. },
  10151. show : function(a) {
  10152. if (a) {
  10153. this.setTarget(a)
  10154. }
  10155. this.callParent([])
  10156. }
  10157. });
  10158. Ext.define("Gnt.feature.TaskDragDrop", {
  10159. extend : "Ext.dd.DragZone",
  10160. requires : ["Gnt.Tooltip", "Ext.dd.StatusProxy", "Ext.dd.ScrollManager"],
  10161. onDragEnter : Ext.emptyFn,
  10162. onDragOut : Ext.emptyFn,
  10163. constructor : function(a) {
  10164. a = a || {};
  10165. Ext.apply(this, a);
  10166. this.proxy = this.proxy || Ext.create("Ext.dd.StatusProxy", {
  10167. shadow : false,
  10168. dropAllowed : "sch-gantt-dragproxy",
  10169. dropNotAllowed : "sch-gantt-dragproxy",
  10170. ensureAttachedToBody : Ext.emptyFn
  10171. });
  10172. var c = this, b = c.gantt;
  10173. if (c.useTooltip) {
  10174. c.tip = Ext.create("Gnt.Tooltip", {
  10175. gantt : b
  10176. })
  10177. }
  10178. c.callParent([b.el, Ext.apply(a, {
  10179. ddGroup : c.gantt.id + "-task-dd"
  10180. })]);
  10181. c.scroll = false;
  10182. c.isTarget = true;
  10183. c.ignoreSelf = false;
  10184. c.addInvalidHandleClass("sch-resizable-handle");
  10185. c.addInvalidHandleClass("x-resizable-handle");
  10186. c.addInvalidHandleClass("sch-gantt-terminal");
  10187. c.addInvalidHandleClass("sch-gantt-progressbar-handle");
  10188. Ext.dd.ScrollManager.register(c.gantt.el);
  10189. c.gantt.ownerCt.el.appendChild(this.proxy.el);
  10190. c.gantt.on({
  10191. destroy : c.cleanUp,
  10192. scope : c
  10193. })
  10194. },
  10195. useTooltip : true,
  10196. validatorFn : function(a, b, d, c) {
  10197. return true
  10198. },
  10199. validatorFnScope : null,
  10200. cleanUp : function() {
  10201. if (this.tip) {
  10202. this.tip.destroy()
  10203. }
  10204. this.destroy()
  10205. },
  10206. containerScroll : false,
  10207. dropAllowed : "sch-gantt-dragproxy",
  10208. dropNotAllowed : "sch-gantt-dragproxy",
  10209. destroy : function() {
  10210. this.callParent(arguments);
  10211. Ext.dd.ScrollManager.unregister(this.gantt.el)
  10212. },
  10213. autoOffset : function(a, e) {
  10214. var d = this.dragData.repairXY, c = a - d[0], b = e - d[1];
  10215. this.setDelta(c, b)
  10216. },
  10217. setXConstraint : function(c, b, a) {
  10218. this.leftConstraint = c;
  10219. this.rightConstraint = b;
  10220. this.minX = c;
  10221. this.maxX = b;
  10222. if (a) {
  10223. this.setXTicks(this.initPageX, a)
  10224. }
  10225. this.constrainX = true
  10226. },
  10227. setYConstraint : function(a, c, b) {
  10228. this.topConstraint = a;
  10229. this.bottomConstraint = c;
  10230. this.minY = a;
  10231. this.maxY = c;
  10232. if (b) {
  10233. this.setYTicks(this.initPageY, b)
  10234. }
  10235. this.constrainY = true
  10236. },
  10237. constrainTo : function(a, b) {
  10238. this.resetConstraints();
  10239. this.initPageX = a.left;
  10240. this.initPageY = b.top;
  10241. this.setXConstraint(a.left, a.right - (b.right - b.left),
  10242. this.xTickSize);
  10243. this.setYConstraint(b.top - 1, b.top - 1, this.yTickSize)
  10244. },
  10245. onDragOver : function(h, i) {
  10246. var g = this.dragData, f = g.record, d = this.gantt, b = this.proxy.el
  10247. .getX()
  10248. + d.getXOffset(f), a = d.getDateFromXY([b, 0], "round");
  10249. if (!g.hidden) {
  10250. Ext.fly(g.sourceNode).hide();
  10251. g.hidden = true
  10252. }
  10253. if (!a || a - g.start === 0) {
  10254. return
  10255. }
  10256. g.start = a;
  10257. this.valid = this.validatorFn.call(this.validatorFnScope || d, f, a,
  10258. g.duration, h) !== false;
  10259. if (this.tip) {
  10260. var c = f.calculateEndDate(a, f.getDuration(), f.getDurationUnit());
  10261. this.updateTip(f, a, c)
  10262. }
  10263. },
  10264. onStartDrag : function() {
  10265. var a = this.dragData.record;
  10266. if (this.tip) {
  10267. this.tip.enable();
  10268. this.tip.show(Ext.get(this.dragData.sourceNode));
  10269. this.updateTip(a, a.getStartDate(), a.getEndDate())
  10270. }
  10271. this.gantt.fireEvent("taskdragstart", this.gantt, a)
  10272. },
  10273. updateTip : function(b, c, a) {
  10274. if (b.isMilestone() && c - Ext.Date.clearTime(c, true) === 0) {
  10275. c = Sch.util.Date.add(c, Sch.util.Date.MILLI, -1);
  10276. a = Sch.util.Date.add(a, Sch.util.Date.MILLI, -1)
  10277. }
  10278. this.tip.update(c, a, true)
  10279. },
  10280. getDragData : function(i) {
  10281. var h = this.gantt, f = i.getTarget(h.eventSelector);
  10282. if (f && !i.getTarget(".sch-gantt-baseline-item")) {
  10283. var c = Ext.get(f), d = h.resolveTaskRecord(c);
  10284. if (h.fireEvent("beforetaskdrag", h, d, i) === false) {
  10285. return null
  10286. }
  10287. var j = f.cloneNode(true), b = h.getSnapPixelAmount(), a = c
  10288. .getXY();
  10289. j.id = Ext.id();
  10290. if (b <= 1) {
  10291. Ext.fly(j).setStyle("left", 0)
  10292. }
  10293. this.constrainTo(Ext.fly(h.findItemByChild(f)).getRegion(), c
  10294. .getRegion());
  10295. if (b >= 1) {
  10296. this.setXConstraint(this.leftConstraint, this.rightConstraint,
  10297. b)
  10298. }
  10299. return {
  10300. sourceNode : f,
  10301. repairXY : a,
  10302. ddel : j,
  10303. record : d,
  10304. duration : Sch.util.Date.getDurationInMinutes(d.getStartDate(),
  10305. d.getEndDate())
  10306. }
  10307. }
  10308. return null
  10309. },
  10310. afterRepair : function() {
  10311. Ext.fly(this.dragData.sourceNode).show();
  10312. if (this.tip) {
  10313. this.tip.hide()
  10314. }
  10315. this.dragging = false
  10316. },
  10317. getRepairXY : function() {
  10318. this.gantt.fireEvent("afterdnd", this.gantt);
  10319. return this.dragData.repairXY
  10320. },
  10321. onDragDrop : function(g, i) {
  10322. var f = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(i), d = this.dragData, b = this.gantt, a = d.record, h = d.start;
  10323. var c = false;
  10324. if (this.tip) {
  10325. this.tip.disable()
  10326. }
  10327. if (this.valid && h && a.getStartDate() - h !== 0) {
  10328. b.taskStore.on("update", function() {
  10329. c = true
  10330. }, null, {
  10331. single : true
  10332. });
  10333. a.setStartDate(h, true, b.taskStore.skipWeekendsDuringDragDrop);
  10334. if (c) {
  10335. b.fireEvent("taskdrop", b, a);
  10336. if (Ext.isIE9) {
  10337. this.proxy.el.setStyle("visibility", "hidden");
  10338. Ext.Function.defer(this.onValidDrop, 10, this, [f, g, i])
  10339. } else {
  10340. this.onValidDrop(f, g, i)
  10341. }
  10342. }
  10343. }
  10344. if (!c) {
  10345. this.onInvalidDrop(f, g, i)
  10346. }
  10347. b.fireEvent("aftertaskdrop", b, a)
  10348. }
  10349. });
  10350. Ext.define("Gnt.feature.DependencyDragDrop", {
  10351. extend : "Ext.util.Observable",
  10352. constructor : function(b) {
  10353. this.addEvents("beforednd", "dndstart", "drop", "afterdnd");
  10354. var a = b.ganttView;
  10355. Ext.apply(this, {
  10356. el : a.el,
  10357. ddGroup : a.id + "-sch-dependency-dd",
  10358. ganttView : a,
  10359. dependencyStore : a.getDependencyStore()
  10360. });
  10361. this.el.on("mousemove", function() {
  10362. this.setupDragZone();
  10363. this.setupDropZone()
  10364. }, this, {
  10365. single : true
  10366. });
  10367. this.callParent(arguments)
  10368. },
  10369. fromText : "From: <strong>{0}</strong> {1}<br/>",
  10370. toText : "To: <strong>{0}</strong> {1}",
  10371. startText : "Start",
  10372. endText : "End",
  10373. useLineProxy : true,
  10374. terminalSelector : ".sch-gantt-terminal",
  10375. destroy : function() {
  10376. if (this.dragZone) {
  10377. this.dragZone.destroy()
  10378. }
  10379. if (this.dropZone) {
  10380. this.dropZone.destroy()
  10381. }
  10382. if (this.lineProxyEl) {
  10383. this.lineProxyEl.destroy()
  10384. }
  10385. },
  10386. initLineProxy : function(b, a) {
  10387. var c = this.lineProxyEl = this.el.createChild({
  10388. cls : "sch-gantt-connector-proxy"
  10389. });
  10390. c.alignTo(b, a ? "l" : "r");
  10391. Ext.apply(this, {
  10392. containerTop : this.el.getTop(),
  10393. containerLeft : this.el.getLeft(),
  10394. startXY : c.getXY(),
  10395. startScrollLeft : this.el.dom.scrollLeft,
  10396. startScrollTop : this.el.dom.scrollTop
  10397. })
  10398. },
  10399. updateLineProxy : function(m) {
  10400. var a = this.lineProxyEl, j = m[0] - this.startXY[0]
  10401. + this.el.dom.scrollLeft - this.startScrollLeft, i = m[1]
  10402. - this.startXY[1] + this.el.dom.scrollTop - this.startScrollTop, b = Math
  10403. .max(1, Math.sqrt(Math.pow(j, 2) + Math.pow(i, 2)) - 2), h = Math
  10404. .atan2(i, j)
  10405. - (Math.PI / 2), e;
  10406. if (Ext.isIE) {
  10407. var k = Math.cos(h), g = Math.sin(h), l = 'progid:DXImageTransform.Microsoft.Matrix(sizingMethod="auto expand", M11 = '
  10408. + k
  10409. + ", M12 = "
  10410. + (-g)
  10411. + ", M21 = "
  10412. + g
  10413. + ", M22 = "
  10414. + k
  10415. + ")", d, f;
  10416. if (this.el.dom.scrollTop !== this.startScrollTop) {
  10417. d = this.startScrollTop - this.containerTop
  10418. } else {
  10419. d = this.el.dom.scrollTop - this.containerTop
  10420. }
  10421. if (this.el.dom.scrollLeft !== this.startScrollLeft) {
  10422. f = this.startScrollLeft - this.containerLeft
  10423. } else {
  10424. f = this.el.dom.scrollLeft - this.containerLeft
  10425. }
  10426. e = {
  10427. height : b + "px",
  10428. top : Math.min(0, i) + this.startXY[1] + d + (i < 0 ? 2 : 0)
  10429. + "px",
  10430. left : Math.min(0, j) + this.startXY[0] + f + (j < 0 ? 2 : 0)
  10431. + "px",
  10432. filter : l,
  10433. "-ms-filter" : l
  10434. }
  10435. } else {
  10436. var c = "rotate(" + h + "rad)";
  10437. e = {
  10438. height : b + "px",
  10439. "-o-transform" : c,
  10440. "-webkit-transform" : c,
  10441. "-moz-transform" : c,
  10442. transform : c
  10443. }
  10444. }
  10445. a.show().setStyle(e)
  10446. },
  10447. setupDragZone : function() {
  10448. var b = this, a = this.ganttView;
  10449. this.dragZone = Ext.create("Ext.dd.DragZone", this.el, {
  10450. ddGroup : this.ddGroup,
  10451. onStartDrag : function() {
  10452. this.el.addCls("sch-gantt-dep-dd-dragging");
  10453. b.fireEvent("dndstart", b);
  10454. if (b.useLineProxy) {
  10455. var c = this.dragData;
  10456. b.initLineProxy(c.sourceNode, c.isStart)
  10457. }
  10458. },
  10459. getDragData : function(g) {
  10460. var f = g.getTarget(b.terminalSelector);
  10461. if (f) {
  10462. var d = a.resolveTaskRecord(f);
  10463. if (b.fireEvent("beforednd", this, d) === false) {
  10464. return null
  10465. }
  10466. var c = !!f.className.match("sch-gantt-terminal-start"), h = Ext.core.DomHelper
  10467. .createDom({
  10468. cls : "sch-dd-dependency",
  10469. children : [{
  10470. tag : "span",
  10471. cls : "sch-dd-dependency-from",
  10472. html : Ext.String.format(
  10473. b.fromText, d.getName(), c
  10474. ? b.startText
  10475. : b.endText)
  10476. }, {
  10477. tag : "span",
  10478. cls : "sch-dd-dependency-to",
  10479. html : Ext.String.format(b.toText,
  10480. "", "")
  10481. }]
  10482. });
  10483. return {
  10484. fromId : d.getId() || d.internalId,
  10485. isStart : c,
  10486. repairXY : Ext.fly(f).getXY(),
  10487. ddel : h,
  10488. sourceNode : Ext.fly(f).up(a.eventSelector)
  10489. }
  10490. }
  10491. return false
  10492. },
  10493. afterRepair : function() {
  10494. this.el.removeCls("sch-gantt-dep-dd-dragging");
  10495. this.dragging = false;
  10496. b.fireEvent("afterdnd", this)
  10497. },
  10498. onMouseUp : function() {
  10499. this.el.removeCls("sch-gantt-dep-dd-dragging");
  10500. if (b.lineProxyEl) {
  10501. if (Ext.isIE) {
  10502. Ext.destroy(b.lineProxyEl);
  10503. b.lineProxyEl = null
  10504. } else {
  10505. b.lineProxyEl.animate({
  10506. to : {
  10507. height : 0
  10508. },
  10509. duration : 500,
  10510. callback : function() {
  10511. Ext.destroy(b.lineProxyEl);
  10512. b.lineProxyEl = null
  10513. }
  10514. })
  10515. }
  10516. }
  10517. },
  10518. getRepairXY : function() {
  10519. return this.dragData.repairXY
  10520. }
  10521. })
  10522. },
  10523. setupDropZone : function() {
  10524. var b = this, a = this.ganttView;
  10525. this.dropZone = Ext.create("Ext.dd.DropZone", this.el, {
  10526. ddGroup : this.ddGroup,
  10527. getTargetFromEvent : function(c) {
  10528. if (b.useLineProxy) {
  10529. b.updateLineProxy(c.getXY())
  10530. }
  10531. return c.getTarget(b.terminalSelector)
  10532. },
  10533. onNodeEnter : function(h, c, g, f) {
  10534. var d = h.className.match("sch-gantt-terminal-start");
  10535. Ext.fly(h).addCls(d
  10536. ? "sch-gantt-terminal-start-drophover"
  10537. : "sch-gantt-terminal-end-drophover")
  10538. },
  10539. onNodeOut : function(h, c, g, f) {
  10540. var d = h.className.match("sch-gantt-terminal-start");
  10541. Ext.fly(h).removeCls(d
  10542. ? "sch-gantt-terminal-start-drophover"
  10543. : "sch-gantt-terminal-end-drophover")
  10544. },
  10545. onNodeOver : function(k, c, j, i) {
  10546. var d = a.resolveTaskRecord(k), f = d.getId() || d.internalId, g = k.className
  10547. .match("sch-gantt-terminal-start"), h = Ext.String
  10548. .format(b.toText, d.getName(), g
  10549. ? b.startText
  10550. : b.endText);
  10551. c.proxy.el.down(".sch-dd-dependency-to").update(h);
  10552. if (b.dependencyStore.isValidDependency(i.fromId, f)) {
  10553. return this.dropAllowed
  10554. } else {
  10555. return this.dropNotAllowed
  10556. }
  10557. },
  10558. onNodeDrop : function(h, l, i, f) {
  10559. var j, c = true, d = Gnt.model.Dependency.Type, g = a
  10560. .resolveTaskRecord(h), k = g.getId() || g.internalId;
  10561. if (b.lineProxyEl) {
  10562. Ext.destroy(b.lineProxyEl);
  10563. b.lineProxyEl = null
  10564. }
  10565. this.el.removeCls("sch-gantt-dep-dd-dragging");
  10566. if (f.isStart) {
  10567. if (h.className.match("sch-gantt-terminal-start")) {
  10568. j = d.StartToStart
  10569. } else {
  10570. j = d.StartToEnd
  10571. }
  10572. } else {
  10573. if (h.className.match("sch-gantt-terminal-start")) {
  10574. j = d.EndToStart
  10575. } else {
  10576. j = d.EndToEnd
  10577. }
  10578. }
  10579. c = b.dependencyStore.isValidDependency(f.fromId, k);
  10580. if (c) {
  10581. b.fireEvent("drop", this, f.fromId, k, j)
  10582. }
  10583. b.fireEvent("afterdnd", this);
  10584. return c
  10585. }
  10586. })
  10587. }
  10588. });
  10589. Ext.define("Gnt.feature.DragCreator", {
  10590. requires : ["Ext.Template", "Sch.util.DragTracker", "Gnt.Tooltip"],
  10591. constructor : function(a) {
  10592. Ext.apply(this, a || {});
  10593. this.init()
  10594. },
  10595. disabled : false,
  10596. showDragTip : true,
  10597. dragTolerance : 2,
  10598. validatorFn : Ext.emptyFn,
  10599. validatorFnScope : null,
  10600. setDisabled : function(a) {
  10601. this.disabled = a;
  10602. if (this.dragTip) {
  10603. this.dragTip.setDisabled(a)
  10604. }
  10605. },
  10606. getProxy : function() {
  10607. if (!this.proxy) {
  10608. this.proxy = this.template.append(
  10609. this.ganttView.ownerCt.el, {}, true)
  10610. }
  10611. return this.proxy
  10612. },
  10613. onBeforeDragStart : function(f) {
  10614. var c = this.ganttView, b = f.getTarget("." + c.timeCellCls, 2);
  10615. if (b) {
  10616. var a = c.resolveTaskRecord(b);
  10617. var d = c.getDateFromDomEvent(f);
  10618. if (!this.disabled
  10619. && b
  10620. && !a.getStartDate()
  10621. && !a.getEndDate()
  10622. && c.fireEvent("beforedragcreate", c, a, d, f) !== false) {
  10623. f.stopEvent();
  10624. this.taskRecord = a;
  10625. this.originalStart = d;
  10626. this.rowRegion = c.getScheduleRegion(this.taskRecord,
  10627. this.originalStart);
  10628. this.dateConstraints = c.getDateConstraints(
  10629. this.resourceRecord, this.originalStart);
  10630. return true
  10631. }
  10632. }
  10633. return false
  10634. },
  10635. onDragStart : function() {
  10636. var c = this, a = c.ganttView, b = c.getProxy();
  10637. c.start = c.originalStart;
  10638. c.end = c.start;
  10639. c.rowBoundaries = {
  10640. top : c.rowRegion.top,
  10641. bottom : c.rowRegion.bottom
  10642. };
  10643. b.setRegion({
  10644. top : c.rowBoundaries.top,
  10645. right : c.tracker.startXY[0],
  10646. bottom : c.rowBoundaries.bottom,
  10647. left : c.tracker.startXY[0]
  10648. });
  10649. b.show();
  10650. c.ganttView.fireEvent("dragcreatestart", c.ganttView);
  10651. if (c.showDragTip) {
  10652. c.dragTip.update(c.start, c.end, true, this.taskRecord);
  10653. c.dragTip.enable();
  10654. c.dragTip.show(b)
  10655. }
  10656. },
  10657. onDrag : function(g) {
  10658. var d = this, c = d.ganttView, b = d.tracker.getRegion()
  10659. .constrainTo(d.rowRegion), f = c
  10660. .getStartEndDatesFromRegion(b, "round");
  10661. if (!f) {
  10662. return
  10663. }
  10664. d.start = f.start || d.start;
  10665. d.end = f.end || d.end;
  10666. var a = d.dateConstraints;
  10667. if (a) {
  10668. d.end = Sch.util.Date.constrain(d.end, a.start, a.end);
  10669. d.start = Sch.util.Date.constrain(d.start, a.start, a.end)
  10670. }
  10671. d.valid = this.validatorFn.call(d.validatorFnScope || d,
  10672. this.taskRecord, d.start, d.end, g) !== false;
  10673. if (d.showDragTip) {
  10674. d.dragTip.update(d.start, d.end, d.valid, this.taskRecord)
  10675. }
  10676. Ext.apply(b, d.rowBoundaries);
  10677. this.getProxy().setRegion(b)
  10678. },
  10679. onDragEnd : function(a) {
  10680. var b = this.ganttView;
  10681. if (this.showDragTip) {
  10682. this.dragTip.disable()
  10683. }
  10684. if (!this.start || !this.end || (this.end < this.start)) {
  10685. this.valid = false
  10686. }
  10687. if (this.valid) {
  10688. this.taskRecord.setStartEndDate(this.start, this.end);
  10689. b.fireEvent("dragcreateend", b, this.taskRecord, a)
  10690. }
  10691. this.proxy.hide();
  10692. b.fireEvent("afterdragcreate", b)
  10693. },
  10694. init : function() {
  10695. var c = this.ganttView, a = c.el, b = Ext.Function.bind;
  10696. this.lastTime = new Date();
  10697. this.template = this.template
  10698. || Ext
  10699. .create(
  10700. "Ext.Template",
  10701. '<div class="sch-gantt-dragcreator-proxy"></div>',
  10702. {
  10703. compiled : true,
  10704. disableFormats : true
  10705. });
  10706. c.on({
  10707. destroy : this.onGanttDestroy,
  10708. scope : this
  10709. });
  10710. this.tracker = new Sch.util.DragTracker({
  10711. el : a,
  10712. tolerance : this.dragTolerance,
  10713. onBeforeStart : b(this.onBeforeDragStart, this),
  10714. onStart : b(this.onDragStart, this),
  10715. onDrag : b(this.onDrag, this),
  10716. onEnd : b(this.onDragEnd, this)
  10717. });
  10718. if (this.showDragTip) {
  10719. this.dragTip = Ext.create("Gnt.Tooltip", {
  10720. mode : "duration",
  10721. cls : "sch-gantt-dragcreate-tip",
  10722. gantt : c
  10723. })
  10724. }
  10725. },
  10726. onGanttDestroy : function() {
  10727. if (this.dragTip) {
  10728. this.dragTip.destroy()
  10729. }
  10730. if (this.tracker) {
  10731. this.tracker.destroy()
  10732. }
  10733. if (this.proxy) {
  10734. Ext.destroy(this.proxy);
  10735. this.proxy = null
  10736. }
  10737. }
  10738. });
  10739. Ext.define("Gnt.feature.LabelEditor", {
  10740. extend : "Ext.Editor",
  10741. labelPosition : "",
  10742. constructor : function(b, a) {
  10743. this.ganttView = b;
  10744. this.ganttView.on("afterrender", this.onGanttRender, this);
  10745. this.callParent([a])
  10746. },
  10747. edit : function(a) {
  10748. var b = this.ganttView.getElementFromEventRecord(a)
  10749. .up(this.ganttView.eventWrapSelector);
  10750. this.record = a;
  10751. this.startEdit(b.down(this.delegate), this.dataIndex ? a
  10752. .get(this.dataIndex) : "")
  10753. },
  10754. delegate : "",
  10755. dataIndex : "",
  10756. shadow : false,
  10757. completeOnEnter : true,
  10758. cancelOnEsc : true,
  10759. ignoreNoChange : true,
  10760. onGanttRender : function(a) {
  10761. if (!this.field.width) {
  10762. this.autoSize = "width"
  10763. }
  10764. this.on({
  10765. beforestartedit : function(c, b, d) {
  10766. return a.fireEvent("labeledit_beforestartedit",
  10767. a, this.record, d, c)
  10768. },
  10769. beforecomplete : function(c, d, b) {
  10770. return a.fireEvent("labeledit_beforecomplete",
  10771. a, d, b, this.record, c)
  10772. },
  10773. complete : function(c, d, b) {
  10774. this.record.set(this.dataIndex, d);
  10775. a.fireEvent("labeledit_complete", a, d, b,
  10776. this.record, c)
  10777. },
  10778. scope : this
  10779. });
  10780. a.el.on("dblclick", function(c, b) {
  10781. this.edit(a.resolveTaskRecord(b))
  10782. }, this, {
  10783. delegate : this.delegate
  10784. })
  10785. }
  10786. });
  10787. Ext.define("Gnt.feature.ProgressBarResize", {
  10788. requires : ["Ext.ToolTip", "Ext.resizer.Resizer"],
  10789. constructor : function(a) {
  10790. Ext.apply(this, a || {});
  10791. var b = this.gantt;
  10792. b.on({
  10793. destroy : this.cleanUp,
  10794. scope : this
  10795. });
  10796. b.mon(b.el, "mousedown", this.onMouseDown, this, {
  10797. delegate : ".sch-gantt-progressbar-handle"
  10798. });
  10799. this.callParent(arguments)
  10800. },
  10801. useTooltip : true,
  10802. increment : 10,
  10803. onMouseDown : function(d, b) {
  10804. var c = this.gantt, f = c.resolveTaskRecord(b);
  10805. if (c.fireEvent("beforeprogressbarresize", c, f) !== false) {
  10806. var a = Ext.fly(b).prev(".sch-gantt-progress-bar");
  10807. d.stopEvent();
  10808. this.createResizable(a, f, d);
  10809. c.fireEvent("progressbarresizestart", c, f)
  10810. }
  10811. },
  10812. createResizable : function(d, a, h) {
  10813. var c = h.getTarget(), i = d.up(this.gantt.eventSelector), g = i
  10814. .getWidth()
  10815. - 4, b = g * this.increment / 100;
  10816. var f = Ext.create("Ext.resizer.Resizer", {
  10817. target : d,
  10818. taskRecord : a,
  10819. handles : "e",
  10820. minWidth : 0,
  10821. maxWidth : g,
  10822. minHeight : 1,
  10823. widthIncrement : b,
  10824. listeners : {
  10825. resizedrag : this.partialResize,
  10826. resize : this.afterResize,
  10827. scope : this
  10828. }
  10829. });
  10830. f.resizeTracker.onMouseDown(h, f.east.dom);
  10831. i
  10832. .select(".x-resizable-handle, .sch-gantt-terminal, .sch-gantt-progressbar-handle")
  10833. .hide();
  10834. if (this.useTooltip) {
  10835. if (!this.tip) {
  10836. this.tip = Ext.create("Ext.ToolTip", {
  10837. autoHide : false,
  10838. anchor : "b",
  10839. html : "%"
  10840. })
  10841. }
  10842. this.tip.setTarget(d);
  10843. this.tip.show();
  10844. this.tip.body.update(a.getPercentDone() + "%")
  10845. }
  10846. },
  10847. partialResize : function(c, b) {
  10848. var a = Math.round(b * 100 / (c.maxWidth * this.increment))
  10849. * this.increment;
  10850. if (this.tip) {
  10851. this.tip.body.update(a + "%")
  10852. }
  10853. },
  10854. afterResize : function(d, a, b, f) {
  10855. var g = d.taskRecord;
  10856. if (this.tip) {
  10857. this.tip.hide()
  10858. }
  10859. var c = Math.round(a * 100 / (d.maxWidth * this.increment))
  10860. * this.increment;
  10861. d.taskRecord.setPercentDone(c);
  10862. d.destroy();
  10863. this.gantt.fireEvent("afterprogressbarresize", this.gantt, g)
  10864. },
  10865. cleanUp : function() {
  10866. if (this.tip) {
  10867. this.tip.destroy()
  10868. }
  10869. }
  10870. });
  10871. Ext.define("Gnt.feature.TaskResize", {
  10872. constructor : function(a) {
  10873. Ext.apply(this, a);
  10874. var b = this.gantt;
  10875. b.on({
  10876. destroy : this.cleanUp,
  10877. scope : this
  10878. });
  10879. b.mon(b.el, "mousedown", this.onMouseDown, this, {
  10880. delegate : ".sch-resizable-handle"
  10881. });
  10882. this.callParent(arguments)
  10883. },
  10884. showDuration : true,
  10885. useTooltip : true,
  10886. validatorFn : Ext.emptyFn,
  10887. validatorFnScope : null,
  10888. onMouseDown : function(f) {
  10889. var b = this.gantt, a = f.getTarget(b.eventSelector), g = b
  10890. .resolveTaskRecord(a);
  10891. var c = a.className.match("start") ? "west" : "east";
  10892. var d = g.isResizable();
  10893. if (d === false || typeof d === "string" && !a.className.match(d)) {
  10894. return
  10895. }
  10896. if (b.fireEvent("beforetaskresize", b, g, f) === false) {
  10897. return
  10898. }
  10899. f.stopEvent();
  10900. this.createResizable(Ext.get(a), g, f);
  10901. b.fireEvent("taskresizestart", b, g)
  10902. },
  10903. createResizable : function(c, k, j) {
  10904. var m = j.getTarget(), i = this.gantt, a = !!m.className
  10905. .match("sch-resizable-handle-west"), d = i.getSnapPixelAmount(), f = c
  10906. .getWidth(), l = c.up(".x-grid-row").getRegion();
  10907. this.resizable = Ext.create("Ext.resizer.Resizer", {
  10908. startLeft : c.getLeft(),
  10909. startRight : c.getRight(),
  10910. target : c,
  10911. taskRecord : k,
  10912. handles : a ? "w" : "e",
  10913. constrainTo : l,
  10914. minHeight : 1,
  10915. minWidth : d,
  10916. widthIncrement : d,
  10917. listeners : {
  10918. resizedrag : this[a ? "partialWestResize" : "partialEastResize"],
  10919. resize : this.afterResize,
  10920. scope : this
  10921. }
  10922. });
  10923. this.resizable.resizeTracker.onMouseDown(j, this.resizable[a
  10924. ? "west"
  10925. : "east"].dom);
  10926. if (this.useTooltip) {
  10927. if (!this.tip) {
  10928. this.tip = Ext.create("Gnt.Tooltip", {
  10929. mode : this.showDuration ? "duration" : "startend",
  10930. gantt : this.gantt
  10931. })
  10932. }
  10933. var b = k.getStartDate(), h = k.getEndDate();
  10934. this.tip.show(c);
  10935. this.tip.update(b, h, true, k)
  10936. }
  10937. },
  10938. partialEastResize : function(i, f, b, g) {
  10939. var c = this.gantt, a = c.getDateFromXY([
  10940. i.startLeft + Math.min(f, this.resizable.maxWidth), 0],
  10941. "round");
  10942. if (!a || i.end - a === 0) {
  10943. return
  10944. }
  10945. var h = i.taskRecord.getStartDate(), d = this.validatorFn.call(
  10946. this.validatorFnScope || this, i.taskRecord, h, a) !== false;
  10947. i.end = a;
  10948. c.fireEvent("partialtaskresize", c, i.taskRecord, h, a, i.el, g);
  10949. if (this.useTooltip) {
  10950. this.tip.update(h, a, d, i.taskRecord)
  10951. }
  10952. },
  10953. partialWestResize : function(i, f, b, g) {
  10954. var c = this.gantt, h = c.getDateFromXY(
  10955. [i.startRight - Math.min(f, this.resizable.maxWidth), 0],
  10956. "round");
  10957. if (!h || i.start - h === 0) {
  10958. return
  10959. }
  10960. var a = i.taskRecord.getEndDate(), d = this.validatorFn.call(
  10961. this.validatorFnScope || this, i.taskRecord, h, a) !== false;
  10962. i.start = h;
  10963. c.fireEvent("partialtaskresize", c, i.taskRecord, h, a, i.el, g);
  10964. if (this.useTooltip) {
  10965. this.tip.update(h, a, d, i.taskRecord)
  10966. }
  10967. },
  10968. afterResize : function(a, l, i, j) {
  10969. if (this.useTooltip) {
  10970. this.tip.hide()
  10971. }
  10972. var k = a.taskRecord, g = k.getStartDate(), m = k.getEndDate(), c = a.start
  10973. || g, f = a.end || m, d = this.gantt;
  10974. a.destroy();
  10975. if (c
  10976. && f
  10977. && (c - g || f - m)
  10978. && this.validatorFn.call(this.validatorFnScope || this, k, c,
  10979. f, j) !== false) {
  10980. var b = this.gantt.taskStore.skipWeekendsDuringDragDrop;
  10981. if (c - g !== 0) {
  10982. k.setStartDate(c <= f ? c : f, false, b)
  10983. } else {
  10984. k.setEndDate(c <= f ? f : c, false, b)
  10985. }
  10986. } else {
  10987. d.refreshKeepingScroll()
  10988. }
  10989. d.fireEvent("aftertaskresize", d, k)
  10990. },
  10991. cleanUp : function() {
  10992. if (this.tip) {
  10993. this.tip.destroy()
  10994. }
  10995. }
  10996. });
  10997. Ext.define("Gnt.feature.WorkingTime", {
  10998. extend : "Sch.plugin.Zones",
  10999. requires : ["Ext.data.Store", "Sch.model.Range"],
  11000. expandToFitView : true,
  11001. calendar : null,
  11002. init : function(a) {
  11003. if (!this.calendar) {
  11004. Ext.Error
  11005. .raise("Required attribute 'calendar' missed during initialization of 'Gnt.feature.WorkingTime'")
  11006. }
  11007. this.bindCalendar(this.calendar);
  11008. Ext.apply(this, {
  11009. store : new Ext.data.Store({
  11010. model : "Sch.model.Range"
  11011. })
  11012. });
  11013. this.callParent(arguments);
  11014. a.on("viewchange", this.onViewChange, this);
  11015. this.onViewChange()
  11016. },
  11017. bindCalendar : function(b) {
  11018. var a = {
  11019. datachanged : this.refresh,
  11020. update : this.refresh,
  11021. scope : this,
  11022. delay : 1
  11023. };
  11024. if (this.calendar) {
  11025. this.calendar.un(a)
  11026. }
  11027. b.on(a);
  11028. this.calendar = b
  11029. },
  11030. onViewChange : function() {
  11031. var a = Sch.util.Date;
  11032. if (a.compareUnits(this.timeAxis.unit, a.WEEK) > 0) {
  11033. this.setDisabled(true)
  11034. } else {
  11035. this.setDisabled(false);
  11036. this.refresh()
  11037. }
  11038. },
  11039. refresh : function() {
  11040. var a = this.schedulerView;
  11041. this.store.removeAll(true);
  11042. this.store.add(this.calendar.getHolidaysRanges(a.getStart(),
  11043. a.getEnd(), true))
  11044. }
  11045. });
  11046. Ext.define("Gnt.plugin.DependencyEditor", {
  11047. extend : "Ext.form.FormPanel",
  11048. mixins : ["Ext.AbstractPlugin"],
  11049. lockableScope : "normal",
  11050. requires : ["Ext.form.DisplayField", "Ext.form.ComboBox",
  11051. "Ext.form.NumberField", "Gnt.model.Dependency"],
  11052. hideOnBlur : true,
  11053. fromText : "From",
  11054. toText : "To",
  11055. typeText : "Type",
  11056. lagText : "Lag",
  11057. endToStartText : "Finish-To-Start",
  11058. startToStartText : "Start-To-Start",
  11059. endToEndText : "Finish-To-Finish",
  11060. startToEndText : "Start-To-Finish",
  11061. showLag : false,
  11062. border : false,
  11063. height : 150,
  11064. width : 260,
  11065. frame : true,
  11066. labelWidth : 60,
  11067. constrain : false,
  11068. initComponent : function() {
  11069. Ext.apply(this, {
  11070. items : this.buildFields(),
  11071. defaults : {
  11072. width : 240
  11073. },
  11074. floating : true,
  11075. hideMode : "offsets"
  11076. });
  11077. this.callParent(arguments)
  11078. },
  11079. beforeRender : function() {
  11080. this.addCls("sch-gantt-dependencyeditor");
  11081. this.callParent(arguments)
  11082. },
  11083. init : function(a) {
  11084. a.on({
  11085. dependencydblclick : this.onDependencyDblClick,
  11086. destroy : this.destroy,
  11087. scope : this
  11088. });
  11089. a.on("afterrender", this.onGanttRender, this, {
  11090. delay : 50
  11091. });
  11092. this.gantt = a;
  11093. this.taskStore = a.getTaskStore()
  11094. },
  11095. onGanttRender : function() {
  11096. this.render(Ext.getBody());
  11097. this.collapse(Ext.Component.DIRECTION_TOP, true);
  11098. this.hide();
  11099. if (this.hideOnBlur) {
  11100. this.mon(Ext.getBody(), "click", this.onMouseClick, this)
  11101. }
  11102. },
  11103. show : function(a, b) {
  11104. this.dependencyRecord = a;
  11105. this.getForm().loadRecord(a);
  11106. this.fromLabel
  11107. .setValue(this.dependencyRecord.getSourceTask().getName());
  11108. this.toLabel.setValue(this.dependencyRecord.getTargetTask().getName());
  11109. this.callParent([]);
  11110. this.el.setXY(b);
  11111. this.expand(!this.constrain);
  11112. if (this.constrain) {
  11113. this.doConstrain(Ext.util.Region.getRegion(Ext.getBody()))
  11114. }
  11115. },
  11116. buildFields : function() {
  11117. var c = this, d = Gnt.model.Dependency, b = d.Type, a = [
  11118. this.fromLabel = Ext.create("Ext.form.DisplayField", {
  11119. fieldLabel : this.fromText
  11120. }),
  11121. this.toLabel = Ext.create("Ext.form.DisplayField", {
  11122. fieldLabel : this.toText
  11123. }), this.typeField = Ext.create("Ext.form.ComboBox", {
  11124. name : d.prototype.nameField,
  11125. fieldLabel : this.typeText,
  11126. triggerAction : "all",
  11127. queryMode : "local",
  11128. valueField : "value",
  11129. displayField : "text",
  11130. editable : false,
  11131. store : Ext.create("Ext.data.JsonStore", {
  11132. fields : ["text", "value"],
  11133. data : [{
  11134. text : this.endToStartText,
  11135. value : b.EndToStart
  11136. }, {
  11137. text : this.startToStartText,
  11138. value : b.StartToStart
  11139. }, {
  11140. text : this.endToEndText,
  11141. value : b.EndToEnd
  11142. }, {
  11143. text : this.startToEndText,
  11144. value : b.StartToEnd
  11145. }]
  11146. })
  11147. })];
  11148. if (this.showLag) {
  11149. a.push(this.lagField = Ext.create("Ext.form.NumberField", {
  11150. name : d.prototype.lagField,
  11151. fieldLabel : this.lagText
  11152. }))
  11153. }
  11154. return a
  11155. },
  11156. onDependencyDblClick : function(c, a, d, b) {
  11157. if (this.lagField) {
  11158. this.lagField.name = a.lagField
  11159. }
  11160. if (this.typeField) {
  11161. this.typeField.name = a.typeField
  11162. }
  11163. if (a != this.dependencyRecord) {
  11164. this.show(a, d.getXY())
  11165. }
  11166. },
  11167. onMouseClick : function(a) {
  11168. if (this.collapsed || a.within(this.getEl()) || a.getTarget(".x-layer")
  11169. || a.getTarget(".sch-ignore-click")) {
  11170. return
  11171. }
  11172. this.collapse()
  11173. },
  11174. afterCollapse : function() {
  11175. delete this.dependencyRecord;
  11176. this.hide();
  11177. this.callParent(arguments)
  11178. }
  11179. });
  11180. Ext.define("Gnt.plugin.TaskContextMenu", {
  11181. extend : "Ext.menu.Menu",
  11182. mixins : ["Ext.AbstractPlugin"],
  11183. lockableScope : "top",
  11184. requires : ["Gnt.model.Dependency"],
  11185. plain : true,
  11186. triggerEvent : "taskcontextmenu",
  11187. texts : {
  11188. newTaskText : "新建任务",
  11189. newMilestoneText : "新建里程碑",
  11190. deleteTask : "删除任务",
  11191. scanDetails:'查看进度详情',
  11192. editLeftLabel : "编辑左标注",
  11193. editRightLabel : "编辑右标注",
  11194. add : "添加",
  11195. deleteDependency : "删除依赖关系",
  11196. addTaskAbove : "向上添加任务",
  11197. addTaskBelow : "向下添加任务",
  11198. addMilestone : "添加里程碑",
  11199. addSubtask : "添加子任务",
  11200. addSuccessor : "添加继承者",
  11201. addPredecessor : "添加前任者"
  11202. },
  11203. grid : null,
  11204. rec : null,
  11205. lastHighlightedItem : null,
  11206. createMenuItems : function() {
  11207. var a = this.texts;
  11208. return [{
  11209. iconCls:'x-menu-scan',
  11210. handler:this.scanDetails,
  11211. requiresTask : true,
  11212. scope : this,
  11213. text : a.scanDetails,
  11214. },
  11215. {
  11216. iconCls:'x-menu-delete',
  11217. handler : this.deleteTask,
  11218. requiresTask : true,
  11219. scope : this,
  11220. text : a.deleteTask
  11221. }, {
  11222. iconCls:'x-menu-edit',
  11223. handler : this.editLeftLabel,
  11224. requiresTask : true,
  11225. scope : this,
  11226. text : a.editLeftLabel
  11227. }, {
  11228. iconCls:'x-menu-edit',
  11229. handler : this.editRightLabel,
  11230. requiresTask : true,
  11231. scope : this,
  11232. text : a.editRightLabel
  11233. }, {
  11234. iconCls:'x-menu-add',
  11235. text : a.add,
  11236. menu : {
  11237. plain : true,
  11238. items : [{
  11239. iconCls:'x-menu-add-up',
  11240. handler : this.addTaskAboveAction,
  11241. requiresTask : true,
  11242. scope : this,
  11243. text : a.addTaskAbove
  11244. }, {
  11245. iconCls:'x-menu-add-down',
  11246. handler : this.addTaskBelowAction,
  11247. scope : this,
  11248. text : a.addTaskBelow
  11249. }, {
  11250. iconCls:'x-menu-menu-add',
  11251. handler : this.addMilestone,
  11252. requiresTask : true,
  11253. scope : this,
  11254. text : a.addMilestone
  11255. }, {
  11256. iconCls:'x-menu-menu-add',
  11257. handler : this.addSubtask,
  11258. requiresTask : true,
  11259. scope : this,
  11260. text : a.addSubtask
  11261. }, {
  11262. iconCls:'x-menu-menu-add',
  11263. handler : this.addSuccessor,
  11264. requiresTask : true,
  11265. scope : this,
  11266. text : a.addSuccessor
  11267. }, {
  11268. iconCls:'x-menu-menu-add',
  11269. handler : this.addPredecessor,
  11270. requiresTask : true,
  11271. scope : this,
  11272. text : a.addPredecessor
  11273. }]
  11274. }
  11275. }, {
  11276. iconCls:'x-menu-delete-dependency',
  11277. text : a.deleteDependency,
  11278. requiresTask : true,
  11279. menu : {
  11280. plain : true,
  11281. listeners : {
  11282. beforeshow : this.populateDependencyMenu,
  11283. mouseover : this.onDependencyMouseOver,
  11284. mouseleave : this.onDependencyMouseOut,
  11285. scope : this
  11286. }
  11287. }
  11288. }]
  11289. },
  11290. buildMenuItems : function() {
  11291. this.items = this.createMenuItems()
  11292. },
  11293. initComponent : function() {
  11294. this.buildMenuItems();
  11295. this.callParent(arguments)
  11296. },
  11297. init : function(b) {
  11298. b.on("destroy", this.cleanUp, this);
  11299. var a = b.getSchedulingView(), c = b.lockedGrid.getView();
  11300. if (this.triggerEvent === "itemcontextmenu") {
  11301. c.on("itemcontextmenu", this.onItemContextMenu, this);
  11302. a.on("itemcontextmenu", this.onItemContextMenu, this)
  11303. }
  11304. a.on("taskcontextmenu", this.onTaskContextMenu, this);
  11305. a.on("containercontextmenu", this.onContainerContextMenu, this);
  11306. c.on("containercontextmenu", this.onContainerContextMenu, this);
  11307. this.grid = b
  11308. },
  11309. populateDependencyMenu : function(f) {
  11310. var d = this.grid, b = d.getTaskStore(), e = this.rec
  11311. .getAllDependencies(), a = d.dependencyStore;
  11312. f.removeAll();
  11313. if (e.length === 0) {
  11314. return false
  11315. }
  11316. var c = this.rec.getId() || this.rec.internalId;
  11317. Ext.each(e, function(i) {
  11318. var h = i.getSourceId(), g = b.getById(h == c ? i
  11319. .getTargetId() : h);
  11320. if (g.data.children!=null) {
  11321. f.add({
  11322. iconCls:'x-tree-icon-parent',
  11323. depId : i.internalId,
  11324. text : Ext.util.Format.ellipsis(
  11325. g.getName(), 30),
  11326. scope : this,
  11327. handler : function(k) {
  11328. var j;
  11329. a.each(function(l) {
  11330. if (l.internalId == k.depId) {
  11331. j = l;
  11332. return false
  11333. }
  11334. });
  11335. a.remove(j)
  11336. }
  11337. })
  11338. }else{
  11339. f.add({
  11340. iconCls:'x-tree-icon-leaf',
  11341. depId : i.internalId,
  11342. text : Ext.util.Format.ellipsis(
  11343. g.getName(), 30),
  11344. scope : this,
  11345. handler : function(k) {
  11346. var j;
  11347. a.each(function(l) {
  11348. if (l.internalId == k.depId) {
  11349. j = l;
  11350. return false
  11351. }
  11352. });
  11353. a.remove(j)
  11354. }
  11355. })
  11356. }
  11357. }, this)
  11358. },
  11359. onDependencyMouseOver : function(d, a, b) {
  11360. if (a) {
  11361. var c = this.grid.getSchedulingView();
  11362. if (this.lastHighlightedItem) {
  11363. c.unhighlightDependency(this.lastHighlightedItem.depId)
  11364. }
  11365. this.lastHighlightedItem = a;
  11366. c.highlightDependency(a.depId)
  11367. }
  11368. },
  11369. onDependencyMouseOut : function(b, a) {
  11370. if (this.lastHighlightedItem) {
  11371. this.grid.getSchedulingView()
  11372. .unhighlightDependency(this.lastHighlightedItem.depId)
  11373. }
  11374. },
  11375. cleanUp : function() {
  11376. this.destroy()
  11377. },
  11378. onTaskContextMenu : function(b, a, c) {
  11379. this.activateMenu(a, c)
  11380. },
  11381. onItemContextMenu : function(b, a, d, c, f) {
  11382. this.activateMenu(a, f)
  11383. },
  11384. onContainerContextMenu : function(a, b) {
  11385. this.activateMenu(null, b)
  11386. },
  11387. activateMenu : function(b, a) {
  11388. if (this.grid.isReadOnly()) {
  11389. return
  11390. }
  11391. a.stopEvent();
  11392. this.rec = b;
  11393. this.configureMenuItems();
  11394. this.showAt(a.getXY())
  11395. },
  11396. configureMenuItems : function() {
  11397. var b = this.query("[requiresTask]");
  11398. var c = this.rec;
  11399. Ext.each(b, function(d) {
  11400. d.setDisabled(!c)
  11401. });
  11402. var a = this.query("[isDependenciesMenu]")[0];
  11403. if (c && a) {
  11404. a.setDisabled(!c.getAllDependencies().length)
  11405. }
  11406. },
  11407. copyTask : function(c) {
  11408. var b = this.grid.getTaskStore().model;
  11409. var a = new b({
  11410. leaf : true
  11411. });
  11412. //2012-11-29 zhouy
  11413. a.set("prjplanid",projectplandata.prjplan_id);
  11414. a.set("prjplanname",projectplandata.prjplan_prjname);
  11415. a.set('taskcode',BaseUtil.getSerialNumber('M'+projectplandata.prjplan_id,'ProjectTask'));
  11416. a.setPercentDone(0);
  11417. a.setName(this.texts.newTaskText);
  11418. a.set(type,1);
  11419. a.set(a.startDateField, (c && c.getStartDate()) || null);
  11420. a.set(a.endDateField, (c && c.getEndDate()) || null);
  11421. a.set(a.durationField, (c && c.getDuration()) || null);
  11422. a.set(a.durationUnitField, (c && c.getDurationUnit()) || "d");
  11423. return a
  11424. },
  11425. addTaskAbove : function(a) {
  11426. var b = this.rec;
  11427. if (b) {
  11428. b.addTaskAbove(a)
  11429. } else {
  11430. this.grid.taskStore.getRootNode().appendChild(a)
  11431. }
  11432. },
  11433. addTaskBelow : function(a) {
  11434. var b = this.rec;
  11435. if (b) {
  11436. b.addTaskBelow(a)
  11437. } else {
  11438. this.grid.taskStore.getRootNode().appendChild(a)
  11439. }
  11440. },
  11441. deleteTask : function() {
  11442. var a = this.grid.getSelectionModel().selected;
  11443. if(a.items[0].data.type==0){
  11444. this.grid.taskStore.remove(a.items);
  11445. }else showError('该任务是里程碑不能删除');
  11446. },
  11447. scanDetails:function(){
  11448. var a = this.grid.getSelectionModel().selected;
  11449. var data=a.items[0].data;
  11450. if(!data.leaf){
  11451. showError('请选择子任务查看');
  11452. return ;
  11453. }
  11454. var id=data.Id;
  11455. var title=data.Name;
  11456. var condition="wr_taskid="+id;
  11457. var win = new Ext.window.Window(
  11458. {
  11459. id : 'win',
  11460. height : '90%',
  11461. title:title,
  11462. width :950,
  11463. maximizable : true,
  11464. buttonAlign : 'center',
  11465. layout : 'anchor',
  11466. items : [ {
  11467. tag : 'iframe',
  11468. frame : true,
  11469. layout : 'fit',
  11470. html : '<iframe id="iframe_'+ caller+ '" src="'+ basePath+ 'jsps/plm/record/specialrecord.jsp?gridCondition='+condition+'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  11471. } ],
  11472. });
  11473. win.showAt(window.innerWidth/2-450,10);
  11474. },
  11475. editLeftLabel : function() {
  11476. this.grid.getSchedulingView().editLeftLabel(this.rec)
  11477. },
  11478. editRightLabel : function() {
  11479. this.grid.getSchedulingView().editRightLabel(this.rec)
  11480. },
  11481. addTaskAboveAction : function() {
  11482. this.addTaskAbove(this.copyTask(this.rec))
  11483. },
  11484. addTaskBelowAction : function() {
  11485. this.addTaskBelow(this.copyTask(this.rec))
  11486. },
  11487. addSubtask : function() {
  11488. var a = this.rec;
  11489. a.addSubtask(this.copyTask(a))
  11490. },
  11491. addSuccessor : function() {
  11492. var a = this.rec;
  11493. a.addSuccessor(this.copyTask(a))
  11494. },
  11495. addPredecessor : function() {
  11496. var a = this.rec;
  11497. a.addPredecessor(this.copyTask(a))
  11498. },
  11499. addMilestone : function() {
  11500. var b = this.rec, a = this.copyTask(b);
  11501. b.addTaskBelow(a);
  11502. a.setStartEndDate(b.getEndDate(), b.getEndDate())
  11503. }
  11504. });
  11505. Ext.define("Gnt.plugin.Export", {
  11506. extend : "Sch.plugin.PdfExport",
  11507. alternateClassName : "Gnt.plugin.PdfExport",
  11508. showExportDialog : function() {
  11509. this.exportDialogConfig.scrollerDisabled = true;
  11510. this.callParent(arguments)
  11511. },
  11512. getExportJsonHtml : function(d, g) {
  11513. var b = this.scheduler.getSchedulingView(), c = b.dependencyView, a = c.painter
  11514. .getDependencyTplData(b.dependencyStore.getRange()), e = c.lineTpl
  11515. .apply(a), f = {
  11516. dependencies : e,
  11517. rowsAmount : d.rowsAmount,
  11518. columnsAmountNormal : d.columnsAmountNormal,
  11519. columnsAmountLocked : d.columnsAmountLocked,
  11520. timeColumnWidth : d.timeColumnWidth,
  11521. lockedGridWidth : d.lockedGridWidth,
  11522. rowHeight : d.rowHeight
  11523. };
  11524. d.panelHTML = f;
  11525. return this.callParent(arguments)
  11526. },
  11527. resizePanelHTML : function(e) {
  11528. var f = this.callParent(arguments), b = f
  11529. .select(".sch-dependencyview-ct").first(), d = e.k
  11530. * e.rowsAmount * e.rowHeight, c = e.i * e.timeColumnWidth
  11531. * (e.i === 1 ? e.columnsAmountLocked : e.columnsAmountNormal);
  11532. b.dom.innerHTML = e.dependencies;
  11533. b.applyStyles({
  11534. top : -d + "px",
  11535. left : -c + "px"
  11536. });
  11537. var a = f.select(".x-splitter").first();
  11538. a.setHeight("100%");
  11539. return f
  11540. }
  11541. });
  11542. Ext.define("Gnt.plugin.Printable", {
  11543. extend : "Sch.plugin.Printable",
  11544. getGridContent : function(e) {
  11545. var a = this.callParent(arguments), j = e.getSchedulingView(), h = j.dependencyView, n = h.painter
  11546. .getDependencyTplData(j.dependencyStore.getRange()), d = h.lineTpl
  11547. .apply(n), m = a.normalRows;
  11548. if (Ext.select(".sch-gantt-critical-chain").first()) {
  11549. var b = Ext.DomHelper.createDom({
  11550. tag : "div",
  11551. html : d
  11552. });
  11553. b = Ext.get(b);
  11554. var p = Ext.DomHelper.createDom({
  11555. tag : "div",
  11556. html : m
  11557. });
  11558. p = Ext.get(p);
  11559. var q = j.getCriticalPaths(), c = j.dependencyStore, o, g, f, k;
  11560. Ext.each(q, function(i) {
  11561. for (g = 0, f = i.length; g < f; g++) {
  11562. o = i[g];
  11563. this.highlightTask(o, e, p);
  11564. if (g < (f - 1)) {
  11565. k = c.getAt(c.findBy(function(l) {
  11566. return l.getTargetId() === (o.getId() || o.internalId)
  11567. && l.getSourceId() === (i[g + 1].getId() || i[g
  11568. + 1].internalId)
  11569. }));
  11570. this.highlightDependency(k, b, h)
  11571. }
  11572. }
  11573. }, this);
  11574. m = p.getHTML();
  11575. d = b.getHTML()
  11576. }
  11577. a.normalRows = d + m;
  11578. return a
  11579. },
  11580. highlightTask : function(b, a, e) {
  11581. var d = a.getSchedulingView().getElementFromEventRecord(b), c = d.id;
  11582. if (d) {
  11583. e.select("#" + c).first().parent("tr")
  11584. .addCls("sch-gantt-task-highlighted")
  11585. }
  11586. },
  11587. highlightDependency : function(c, b, a) {
  11588. var d = c instanceof Ext.data.Model ? c.internalId : c;
  11589. return b.select(".sch-dep-" + d).addCls(a.selectedCls)
  11590. }
  11591. });
  11592. Ext.define("Gnt.view.DependencyPainter", {
  11593. requires : ["Ext.util.Region"],
  11594. constructor : function(a) {
  11595. a = a || {};
  11596. Ext.apply(this, a, {
  11597. xOffset : 8,
  11598. yOffset : 7,
  11599. midRowOffset : 6,
  11600. arrowOffset : 8
  11601. })
  11602. },
  11603. getTaskBox : function(q) {
  11604. var h = Sch.util.Date, j = q.getStartDate(), p = q.getEndDate(), m = this.ganttView, d = m
  11605. .getStart(), c = m.getEnd();
  11606. if (!q.isVisible() || !j || !p || !h.intersectSpans(j, p, d, c)) {
  11607. return null
  11608. }
  11609. var e, l = this.taskStore.buffered, b = m.getXYFromDate(h.max(j, d))[0], r = m
  11610. .getXYFromDate(h.min(p, c))[0], a = m.getNodeByRecord(q);
  11611. if (a || l) {
  11612. var t = m.getXOffset(q), n, i, v = q.isMilestone(), u = true;
  11613. if (b > t) {
  11614. b -= t
  11615. }
  11616. r += t - 1;
  11617. if (!v && Ext.isIE) {
  11618. if ((Ext.isIE7 || Ext.isIE6) && !Ext.isIEQuirks) {
  11619. r += 5;
  11620. b -= 2
  11621. } else {
  11622. if ((Ext.isIE6 || Ext.isIE7 || Ext.isIE8) && Ext.isIEQuirks) {
  11623. r += 1;
  11624. b -= 2
  11625. }
  11626. }
  11627. }
  11628. var g = m.el;
  11629. var k = g.getScroll().top;
  11630. if (a) {
  11631. var s = m.getEventNodeByRecord(q);
  11632. if (v) {
  11633. e = Ext.fly(a).getOffsetsTo(g);
  11634. n = e[1] + k;
  11635. i = n + Ext.fly(a).getHeight()
  11636. } else {
  11637. e = Ext.fly(s).getOffsetsTo(g);
  11638. n = e[1] + k;
  11639. i = n + Ext.fly(s).getHeight()
  11640. }
  11641. } else {
  11642. var f = m.store.first();
  11643. var o = m.all.elements;
  11644. if (!f) {
  11645. return null
  11646. }
  11647. if (q.isAbove(f)) {
  11648. a = o[0];
  11649. e = Ext.fly(a).getOffsetsTo(g);
  11650. e[1] -= m.rowHeight
  11651. } else {
  11652. a = o[o.length - 1];
  11653. e = Ext.fly(a).getOffsetsTo(g);
  11654. e[1] += m.rowHeight
  11655. }
  11656. n = e[1] + k;
  11657. i = n + this.rowHeight;
  11658. u = false
  11659. }
  11660. return {
  11661. top : n,
  11662. right : r,
  11663. bottom : i,
  11664. left : b,
  11665. rendered : u
  11666. }
  11667. }
  11668. },
  11669. getRenderData : function(f) {
  11670. var e = f.getSourceTask(), c = f.getTargetTask();
  11671. if (!e || !c) {
  11672. return null
  11673. }
  11674. var a = this.getTaskBox(e);
  11675. var d = this.getTaskBox(c);
  11676. if (this.taskStore.buffered && a && !a.rendered && d && !d.rendered) {
  11677. var g = this.ganttView.store.first();
  11678. var b = this.ganttView.store.last();
  11679. if ((e.isAbove(g) && c.isAbove(g))
  11680. || (b.isAbove(e) && b.isAbove(c))) {
  11681. return null
  11682. }
  11683. }
  11684. return {
  11685. fromBox : a,
  11686. toBox : d
  11687. }
  11688. },
  11689. getDependencyTplData : function(q) {
  11690. var n = this, j = n.taskStore;
  11691. if (!Ext.isArray(q)) {
  11692. q = [q]
  11693. }
  11694. if (q.length === 0 || j.getCount() <= 0) {
  11695. return
  11696. }
  11697. var b = [], a = Gnt.model.Dependency.Type, o = n.ganttView, p, k, g, m, h, c;
  11698. for (var f = 0, d = q.length; f < d; f++) {
  11699. c = q[f];
  11700. var e = this.getRenderData(c);
  11701. if (e) {
  11702. m = e.fromBox;
  11703. h = e.toBox;
  11704. if (m && h) {
  11705. switch (c.getType()) {
  11706. case a.StartToEnd :
  11707. p = n.getStartToEndCoordinates(m, h, c);
  11708. break;
  11709. case a.StartToStart :
  11710. p = n.getStartToStartCoordinates(m, h, c);
  11711. break;
  11712. case a.EndToStart :
  11713. p = n.getEndToStartCoordinates(m, h, c);
  11714. break;
  11715. case a.EndToEnd :
  11716. p = n.getEndToEndCoordinates(m, h, c);
  11717. break;
  11718. default :
  11719. throw "Invalid dependency type: " + c.getType()
  11720. }
  11721. if (p) {
  11722. b.push({
  11723. lineCoordinates : p,
  11724. id : c.internalId,
  11725. cls : c.getCls()
  11726. })
  11727. }
  11728. }
  11729. }
  11730. }
  11731. return b
  11732. },
  11733. getStartToStartCoordinates : function(e, d, c) {
  11734. var b = e.left, g = e.top - 1 + ((e.bottom - e.top) / 2), a = d.left, f = d.top
  11735. - 1 + ((d.bottom - d.top) / 2), h = e.top < d.top
  11736. ? (f - this.yOffset - this.midRowOffset)
  11737. : (f + this.yOffset + this.midRowOffset), i = this.xOffset
  11738. + this.arrowOffset;
  11739. if (b > (a + this.xOffset)) {
  11740. i += (b - a)
  11741. }
  11742. return [{
  11743. x1 : b,
  11744. y1 : g,
  11745. x2 : b - i,
  11746. y2 : g
  11747. }, {
  11748. x1 : b - i,
  11749. y1 : g,
  11750. x2 : b - i,
  11751. y2 : f
  11752. }, {
  11753. x1 : b - i,
  11754. y1 : f,
  11755. x2 : a - this.arrowOffset,
  11756. y2 : f
  11757. }]
  11758. },
  11759. getStartToEndCoordinates : function(g, f, e) {
  11760. var c = g.left, j = g.top - 1 + ((g.bottom - g.top) / 2), a = f.right, h = f.top
  11761. - 1 + ((f.bottom - f.top) / 2), k = g.top < f.top
  11762. ? (h - this.yOffset - this.midRowOffset)
  11763. : (h + this.yOffset + this.midRowOffset), i, b;
  11764. if (a > (c + this.xOffset - this.arrowOffset)
  11765. || Math.abs(a - c) < (2 * (this.xOffset + this.arrowOffset))) {
  11766. b = c - this.xOffset - this.arrowOffset;
  11767. var d = a + this.xOffset + this.arrowOffset;
  11768. i = [{
  11769. x1 : c,
  11770. y1 : j,
  11771. x2 : b,
  11772. y2 : j
  11773. }, {
  11774. x1 : b,
  11775. y1 : j,
  11776. x2 : b,
  11777. y2 : k
  11778. }, {
  11779. x1 : b,
  11780. y1 : k,
  11781. x2 : d,
  11782. y2 : k
  11783. }, {
  11784. x1 : d,
  11785. y1 : k,
  11786. x2 : d,
  11787. y2 : h
  11788. }, {
  11789. x1 : d,
  11790. y1 : h,
  11791. x2 : a + this.arrowOffset,
  11792. y2 : h
  11793. }]
  11794. } else {
  11795. b = c - this.xOffset - this.arrowOffset;
  11796. i = [{
  11797. x1 : c,
  11798. y1 : j,
  11799. x2 : b,
  11800. y2 : j
  11801. }, {
  11802. x1 : b,
  11803. y1 : j,
  11804. x2 : b,
  11805. y2 : h
  11806. }, {
  11807. x1 : b,
  11808. y1 : h,
  11809. x2 : a + this.arrowOffset,
  11810. y2 : h
  11811. }]
  11812. }
  11813. return i
  11814. },
  11815. getEndToStartCoordinates : function(g, f, e) {
  11816. var c = g.right, j = g.top - 1 + ((g.bottom - g.top) / 2), a = f.left, h = f.top
  11817. - 1 + ((f.bottom - f.top) / 2), k = g.top < f.top
  11818. ? (h - this.yOffset - this.midRowOffset)
  11819. : (h + this.yOffset + this.midRowOffset), i, b;
  11820. if (a >= (c - 6) && h > j) {
  11821. b = Math.max(c - 6, a) + this.xOffset - 2;
  11822. h = f.top
  11823. + (e.getTargetTask().isMilestone()
  11824. ? this.rowHeight * 0.18
  11825. : 0);
  11826. i = [{
  11827. x1 : c,
  11828. y1 : j,
  11829. x2 : b,
  11830. y2 : j
  11831. }, {
  11832. x1 : b,
  11833. y1 : j,
  11834. x2 : b,
  11835. y2 : h - this.arrowOffset
  11836. }]
  11837. } else {
  11838. b = c + this.xOffset + this.arrowOffset;
  11839. var d = a - this.xOffset - this.arrowOffset;
  11840. if (h > j || a < (c + 2 * this.arrowOffset)) {
  11841. i = [{
  11842. x1 : c,
  11843. y1 : j,
  11844. x2 : b,
  11845. y2 : j
  11846. }, {
  11847. x1 : b,
  11848. y1 : j,
  11849. x2 : b,
  11850. y2 : k
  11851. }, {
  11852. x1 : b,
  11853. y1 : k,
  11854. x2 : d,
  11855. y2 : k
  11856. }, {
  11857. x1 : d,
  11858. y1 : k,
  11859. x2 : d,
  11860. y2 : h
  11861. }, {
  11862. x1 : d,
  11863. y1 : h,
  11864. x2 : a - this.arrowOffset,
  11865. y2 : h
  11866. }]
  11867. } else {
  11868. i = [{
  11869. x1 : c,
  11870. y1 : j,
  11871. x2 : d,
  11872. y2 : j
  11873. }, {
  11874. x1 : d,
  11875. y1 : j,
  11876. x2 : d,
  11877. y2 : h
  11878. }, {
  11879. x1 : d,
  11880. y1 : h,
  11881. x2 : a - this.arrowOffset,
  11882. y2 : h
  11883. }]
  11884. }
  11885. }
  11886. return i
  11887. },
  11888. getEndToEndCoordinates : function(a, c, e) {
  11889. var d = a.right, g = a.top - 1 + ((a.bottom - a.top) / 2), b = c.right
  11890. + this.arrowOffset, f = c.top - 1 + ((c.bottom - c.top) / 2), h = b
  11891. + this.xOffset + this.arrowOffset;
  11892. if (d > (b + this.xOffset)) {
  11893. h += d - b
  11894. }
  11895. return [{
  11896. x1 : d,
  11897. y1 : g,
  11898. x2 : h,
  11899. y2 : g
  11900. }, {
  11901. x1 : h,
  11902. y1 : g,
  11903. x2 : h,
  11904. y2 : f
  11905. }, {
  11906. x1 : h,
  11907. y1 : f,
  11908. x2 : b,
  11909. y2 : f
  11910. }]
  11911. }
  11912. });
  11913. Ext.define("Gnt.view.Dependency", {
  11914. extend : "Ext.util.Observable",
  11915. requires : ["Gnt.feature.DependencyDragDrop", "Gnt.view.DependencyPainter"],
  11916. containerEl : null,
  11917. ganttView : null,
  11918. painter : null,
  11919. taskStore : null,
  11920. store : null,
  11921. dnd : null,
  11922. lineTpl : null,
  11923. enableDependencyDragDrop : true,
  11924. renderAllDepsBuffered : false,
  11925. dependencyCls : "sch-dependency",
  11926. selectedCls : "sch-dependency-selected",
  11927. dependencyPainterClass : "Gnt.view.DependencyPainter",
  11928. constructor : function(a) {
  11929. this.callParent(arguments);
  11930. var b = this.ganttView;
  11931. b.on({
  11932. refresh : this.renderAllDependenciesBuffered,
  11933. scope : this
  11934. });
  11935. this.bindTaskStore(b.getTaskStore());
  11936. this.bindDependencyStore(a.store);
  11937. if (!this.lineTpl) {
  11938. this.lineTpl = Ext
  11939. .create(
  11940. "Ext.XTemplate",
  11941. '<tpl for=".">'
  11942. + Ext.String
  11943. .format(
  11944. '<tpl for="lineCoordinates"><div class="{0} {lineCls} sch-dep-{parent.id} {0}-line {[this.getSuffixedCls(parent.cls, "-line")]}" style="left:{[Math.min(values.x1, values.x2)]}px;top:{[Math.min(values.y1, values.y2)]}px;width:{[Math.abs(values.x1-values.x2)'
  11945. + (!Ext.isGecko
  11946. && Ext.isBorderBox
  11947. ? "+2"
  11948. : "")
  11949. + "]}px;height:{[Math.abs(values.y1-values.y2)"
  11950. + (!Ext.isGecko
  11951. && Ext.isBorderBox
  11952. ? "+2"
  11953. : "")
  11954. + ']}px"></div></tpl><div style="left:{[values.lineCoordinates[values.lineCoordinates.length - 1].x2]}px;top:{[values.lineCoordinates[values.lineCoordinates.length - 1].y2]}px" class="{0}-arrow-ct {0} sch-dep-{id} {[this.getSuffixedCls(values.cls, "-arrow-ct")]}"><img src="'
  11955. + Ext.BLANK_IMAGE_URL
  11956. + '" class="{0}-arrow {0}-arrow-{[this.getArrowDirection(values.lineCoordinates)]} {[this.getSuffixedCls(values.cls, "-arrow")]}" /></div>',
  11957. this.dependencyCls)
  11958. + "</tpl>", {
  11959. compiled : true,
  11960. disableFormats : true,
  11961. getArrowDirection : function(d) {
  11962. var c = d[d.length - 1];
  11963. if (c.y2 < c.y1) {
  11964. return "up"
  11965. }
  11966. if (c.x1 === c.x2) {
  11967. return "down"
  11968. } else {
  11969. if (c.x1 > c.x2) {
  11970. return "left"
  11971. } else {
  11972. return "right"
  11973. }
  11974. }
  11975. },
  11976. getSuffixedCls : function(c, d) {
  11977. if (c && c.indexOf(" ") != -1) {
  11978. return c.replace(/^\s*(.*)\s*$/, "$1")
  11979. .split(/\s+/).join(d + " ")
  11980. + d
  11981. } else {
  11982. return c + d
  11983. }
  11984. }
  11985. })
  11986. }
  11987. this.painter = Ext.create(this.dependencyPainterClass, Ext.apply({
  11988. rowHeight : b.rowHeight,
  11989. taskStore : this.taskStore,
  11990. view : b
  11991. }, a));
  11992. this.addEvents("beforednd", "dndstart", "drop", "afterdnd",
  11993. "beforecascade", "cascade", "dependencydblclick", "refresh");
  11994. if (this.enableDependencyDragDrop) {
  11995. this.dnd = Ext.create("Gnt.feature.DependencyDragDrop", {
  11996. ganttView : this.ganttView
  11997. });
  11998. this.dnd.on("drop", this.onDependencyDrop, this);
  11999. this.relayEvents(this.dnd, ["beforednd", "dndstart", "afterdnd",
  12000. "drop"])
  12001. }
  12002. this.containerEl = this.containerEl.createChild({
  12003. cls : "sch-dependencyview-ct"
  12004. });
  12005. this.ganttView.mon(this.containerEl, "dblclick",
  12006. this.onDependencyDblClick, this, {
  12007. delegate : "." + this.dependencyCls
  12008. });
  12009. if (b.rendered) {
  12010. this.renderAllDependenciesBuffered()
  12011. }
  12012. },
  12013. bindDependencyStore : function(a) {
  12014. this.depStoreListeners = {
  12015. refresh : this.renderAllDependenciesBuffered,
  12016. load : this.renderAllDependenciesBuffered,
  12017. add : this.onDependencyAdd,
  12018. update : this.onDependencyUpdate,
  12019. remove : this.onDependencyDelete,
  12020. scope : this
  12021. };
  12022. a.on(this.depStoreListeners);
  12023. this.store = a
  12024. },
  12025. unBindDependencyStore : function() {
  12026. if (this.depStoreListeners) {
  12027. this.store.un(this.depStoreListeners)
  12028. }
  12029. },
  12030. bindTaskStore : function(a) {
  12031. var b = this.ganttView;
  12032. this.taskStoreListeners = {
  12033. cascade : this.onTaskStoreCascade,
  12034. "root-fill-start" : this.onRootFillStart,
  12035. remove : this.renderAllDependenciesBuffered,
  12036. insert : this.renderAllDependenciesBuffered,
  12037. append : this.renderAllDependenciesBuffered,
  12038. move : this.renderAllDependenciesBuffered,
  12039. update : this.onTaskUpdated,
  12040. scope : this
  12041. };
  12042. if (b.animate) {
  12043. this.ganttViewListeners = {
  12044. afterexpand : this.renderAllDependenciesBuffered,
  12045. aftercollapse : this.renderAllDependenciesBuffered,
  12046. scope : this
  12047. };
  12048. b.on(this.ganttViewListeners)
  12049. } else {
  12050. Ext.apply(this.taskStoreListeners, {
  12051. expand : this.renderAllDependenciesBuffered,
  12052. collapse : this.renderAllDependenciesBuffered
  12053. })
  12054. }
  12055. a.on(this.taskStoreListeners);
  12056. this.taskStore = a
  12057. },
  12058. onTaskStoreCascade : function(a, b) {
  12059. if (b && b.nbrAffected > 0) {
  12060. this.renderAllDependenciesBuffered()
  12061. }
  12062. },
  12063. unBindTaskStore : function(a) {
  12064. a = a || this.taskStore;
  12065. if (!a) {
  12066. return
  12067. }
  12068. if (this.ganttViewListeners) {
  12069. this.ganttView.un(this.ganttViewListeners)
  12070. }
  12071. a.un(this.taskStoreListeners)
  12072. },
  12073. onRootFillStart : function() {
  12074. var a = this.taskStore;
  12075. this.unBindTaskStore(a);
  12076. this.taskStore.on("root-fill-end", function() {
  12077. this.bindTaskStore(a)
  12078. }, this, {
  12079. single : true
  12080. })
  12081. },
  12082. onDependencyDblClick : function(b, a) {
  12083. var c = this.getRecordForDependencyEl(a);
  12084. this.fireEvent("dependencydblclick", this, c, b, a)
  12085. },
  12086. highlightDependency : function(a) {
  12087. if (!(a instanceof Ext.data.Model)) {
  12088. a = this.getDependencyRecordByInternalId(a)
  12089. }
  12090. this.getElementsForDependency(a).addCls(this.selectedCls)
  12091. },
  12092. unhighlightDependency : function(a) {
  12093. if (!(a instanceof Ext.data.Model)) {
  12094. a = this.getDependencyRecordByInternalId(a)
  12095. }
  12096. this.getElementsForDependency(a).removeCls(this.selectedCls)
  12097. },
  12098. getElementsForDependency : function(a) {
  12099. var b = a instanceof Ext.data.Model ? a.internalId : a;
  12100. return this.containerEl.select(".sch-dep-" + b)
  12101. },
  12102. depRe : new RegExp("sch-dep-([^\\s]+)"),
  12103. getDependencyRecordByInternalId : function(d) {
  12104. var c, b, a;
  12105. for (b = 0, a = this.store.getCount(); b < a; b++) {
  12106. c = this.store.getAt(b);
  12107. if (c.internalId == d) {
  12108. return c
  12109. }
  12110. }
  12111. return null
  12112. },
  12113. getRecordForDependencyEl : function(c) {
  12114. var a = c.className.match(this.depRe), d = null;
  12115. if (a && a[1]) {
  12116. var b = a[1];
  12117. d = this.getDependencyRecordByInternalId(b)
  12118. }
  12119. return d
  12120. },
  12121. renderAllDependenciesBuffered : function() {
  12122. var a = this;
  12123. this.containerEl.update("");
  12124. setTimeout(function() {
  12125. if (!a.ganttView.isDestroyed) {
  12126. a.renderAllDependencies()
  12127. }
  12128. }, 0)
  12129. },
  12130. renderAllDependencies : function() {
  12131. if (!this.containerEl.dom) {
  12132. return
  12133. }
  12134. this.getDependencyElements().remove();
  12135. this.renderDependencies(this.store.data.items);
  12136. this.fireEvent("refresh", this)
  12137. },
  12138. getDependencyElements : function() {
  12139. return this.containerEl.select("." + this.dependencyCls)
  12140. },
  12141. renderDependencies : function(b) {
  12142. if (b) {
  12143. var a = this.painter.getDependencyTplData(b);
  12144. this.lineTpl[Ext.isIE ? "insertFirst" : "append"](this.containerEl,
  12145. a)
  12146. }
  12147. },
  12148. renderTaskDependencies : function(d) {
  12149. var c = [];
  12150. if (!Ext.isArray(d)) {
  12151. d = [d]
  12152. }
  12153. for (var a = 0, b = d.length; a < b; a++) {
  12154. c = c.concat(d[a].getAllDependencies())
  12155. }
  12156. this.renderDependencies(c)
  12157. },
  12158. onDependencyUpdate : function(b, a) {
  12159. this.removeDependencyElements(a, false);
  12160. this.renderDependencies(a)
  12161. },
  12162. onDependencyAdd : function(a, b) {
  12163. this.renderDependencies(b)
  12164. },
  12165. removeDependencyElements : function(a, b) {
  12166. if (b !== false) {
  12167. this.getElementsForDependency(a).fadeOut({
  12168. remove : true
  12169. })
  12170. } else {
  12171. this.getElementsForDependency(a).remove()
  12172. }
  12173. },
  12174. onDependencyDelete : function(b, a) {
  12175. this.removeDependencyElements(a)
  12176. },
  12177. dimEventDependencies : function(a) {
  12178. this.containerEl.select(this.depRe + a).setOpacity(0.2)
  12179. },
  12180. clearSelectedDependencies : function() {
  12181. this.containerEl.select("." + this.selectedCls)
  12182. .removeCls(this.selectedCls)
  12183. },
  12184. onTaskUpdated : function(c, b, a) {
  12185. if (!this.taskStore.cascading
  12186. && a != Ext.data.Model.COMMIT
  12187. && (!b.previous || b.startDateField in b.previous || b.endDateField in b.previous)) {
  12188. this.updateDependencies(b)
  12189. }
  12190. },
  12191. updateDependencies : function(b) {
  12192. if (!Ext.isArray(b)) {
  12193. b = [b]
  12194. }
  12195. var a = this;
  12196. Ext.each(b, function(c) {
  12197. Ext.each(c.getAllDependencies(), function(d) {
  12198. a.removeDependencyElements(d, false)
  12199. })
  12200. });
  12201. this.renderTaskDependencies(b)
  12202. },
  12203. onNewDependencyCreated : function() {
  12204. },
  12205. onDependencyDrop : function(f, d, b, e) {
  12206. var c = this.store;
  12207. var a = new c.model({
  12208. fromTask : d,
  12209. toTask : b,
  12210. type : e
  12211. });
  12212. if (c.isValidDependency(a) && this.onNewDependencyCreated(a) !== false) {
  12213. c.add(a)
  12214. }
  12215. },
  12216. destroy : function() {
  12217. if (this.dnd) {
  12218. this.dnd.destroy()
  12219. }
  12220. this.unBindTaskStore();
  12221. this.unBindDependencyStore()
  12222. }
  12223. });
  12224. Ext.define("Gnt.view.Gantt", {
  12225. extend : "Sch.view.TimelineTreeView",
  12226. alias : ["widget.ganttview"],
  12227. requires : ["Gnt.view.Dependency", "Gnt.model.Task", "Gnt.template.Task",
  12228. "Gnt.template.ParentTask", "Gnt.template.Milestone",
  12229. "Gnt.feature.TaskDragDrop", "Gnt.feature.ProgressBarResize",
  12230. "Gnt.feature.TaskResize", "Sch.view.Horizontal"],
  12231. uses : ["Gnt.feature.LabelEditor", "Gnt.feature.DragCreator"],
  12232. _cmpCls : "sch-ganttview",
  12233. rowHeight : 22,
  12234. barMargin : 4,
  12235. scheduledEventName : "task",
  12236. trackOver : false,
  12237. toggleOnDblClick : false,
  12238. milestoneOffset : 8,
  12239. parentTaskOffset : 6,
  12240. eventSelector : ".sch-gantt-item",
  12241. eventWrapSelector : ".sch-event-wrap",
  12242. progressBarResizer : null,
  12243. taskResizer : null,
  12244. taskDragDrop : null,
  12245. dragCreator : null,
  12246. dependencyView : null,
  12247. resizeConfig : null,
  12248. createConfig : null,
  12249. dragDropConfig : null,
  12250. progressBarResizeConfig : null,
  12251. dependencyViewConfig : null,
  12252. constructor : function(a) {
  12253. var b = a.panel._top;
  12254. Ext.apply(this, {
  12255. taskStore : b.taskStore,
  12256. dependencyStore : b.dependencyStore,
  12257. enableDependencyDragDrop : b.enableDependencyDragDrop,
  12258. enableTaskDragDrop : b.enableTaskDragDrop,
  12259. enableProgressBarResize : b.enableProgressBarResize,
  12260. enableDragCreation : b.enableDragCreation,
  12261. allowParentTaskMove : b.allowParentTaskMove,
  12262. toggleParentTasksOnClick : b.toggleParentTasksOnClick,
  12263. resizeHandles : b.resizeHandles,
  12264. enableBaseline : b.baselineVisible || b.enableBaseline,
  12265. leftLabelField : b.leftLabelField,
  12266. rightLabelField : b.rightLabelField,
  12267. eventTemplate : b.eventTemplate,
  12268. parentEventTemplate : b.parentEventTemplate,
  12269. milestoneTemplate : b.milestoneTemplate,
  12270. resizeConfig : b.resizeConfig,
  12271. createConfig : b.createConfig,
  12272. dragDropConfig : b.dragDropConfig,
  12273. progressBarResizeConfig : b.progressBarResizeConfig
  12274. });
  12275. this.addEvents("taskclick", "taskdblclick", "taskcontextmenu",
  12276. "beforetaskresize", "taskresizestart", "partialtaskresize",
  12277. "aftertaskresize", "beforeprogressbarresize",
  12278. "progressbarresizestart", "afterprogressbarresize",
  12279. "beforetaskdrag", "taskdragstart", "taskdrop", "aftertaskdrop",
  12280. "labeledit_beforestartedit", "labeledit_beforecomplete",
  12281. "labeledit_complete", "beforedependencydrag",
  12282. "dependencydragstart", "dependencydrop",
  12283. "afterdependencydragdrop", "beforedragcreate",
  12284. "dragcreatestart", "dragcreateend", "afterdragcreate");
  12285. this.callParent(arguments)
  12286. },
  12287. initComponent : function() {
  12288. this.configureLabels();
  12289. this.setupGanttEvents();
  12290. this.callParent(arguments);
  12291. this.setupTemplates()
  12292. },
  12293. getDependencyStore : function() {
  12294. return this.dependencyStore
  12295. },
  12296. configureFeatures : function() {
  12297. if (this.enableProgressBarResize !== false) {
  12298. this.progressBarResizer = Ext.create(
  12299. "Gnt.feature.ProgressBarResize", Ext.apply({
  12300. gantt : this
  12301. }, this.progressBarResizeConfig || {}));
  12302. this.on({
  12303. beforeprogressbarresize : this.onBeforeTaskProgressBarResize,
  12304. progressbarresizestart : this.onTaskProgressBarResizeStart,
  12305. afterprogressbarresize : this.onTaskProgressBarResizeEnd,
  12306. scope : this
  12307. })
  12308. }
  12309. if (this.resizeHandles !== "none") {
  12310. this.taskResizer = Ext.create("Gnt.feature.TaskResize", Ext.apply({
  12311. gantt : this,
  12312. validatorFn : this.resizeValidatorFn
  12313. || Ext.emptyFn,
  12314. validatorFnScope : this.validatorFnScope
  12315. || this
  12316. }, this.resizeConfig || {}));
  12317. this.on({
  12318. beforedragcreate : this.onBeforeDragCreate,
  12319. beforetaskresize : this.onBeforeTaskResize,
  12320. taskresizestart : this.onTaskResizeStart,
  12321. aftertaskresize : this.onTaskResizeEnd,
  12322. scope : this
  12323. })
  12324. }
  12325. if (this.enableTaskDragDrop) {
  12326. this.taskDragDrop = Ext.create("Gnt.feature.TaskDragDrop", Ext
  12327. .apply({
  12328. gantt : this,
  12329. validatorFn : this.dndValidatorFn
  12330. || Ext.emptyFn,
  12331. validatorFnScope : this.validatorFnScope
  12332. || this
  12333. }, this.dragDropConfig));
  12334. this.on({
  12335. beforetaskdrag : this.onBeforeTaskDrag,
  12336. taskdragstart : this.onDragDropStart,
  12337. aftertaskdrop : this.onDragDropEnd,
  12338. scope : this
  12339. })
  12340. }
  12341. if (this.enableDragCreation) {
  12342. this.dragCreator = Ext.create("Gnt.feature.DragCreator", Ext.apply(
  12343. {
  12344. ganttView : this,
  12345. validatorFn : this.createValidatorFn
  12346. || Ext.emptyFn,
  12347. validatorFnScope : this.validatorFnScope
  12348. || this
  12349. }, this.createConfig))
  12350. }
  12351. },
  12352. prepareData : function(d, a, b) {
  12353. var c = this, e = {}, f = c.gridDataColumns || c.getGridColumns();
  12354. e[f[0].id] = this.renderTask(b);
  12355. return e
  12356. },
  12357. renderTask : function(k) {
  12358. var l = k.getStartDate(), n = this.timeAxis, s = Sch.util.Date, b = {}, A = "", h = n
  12359. .getStart(), g = n.getEnd(), C = k.isMilestone(), x = k
  12360. .isLeaf(), o, q, u;
  12361. if (l) {
  12362. var v = k.getEndDate()
  12363. || Sch.util.Date.add(l, Sch.util.Date.DAY, 1), e = Sch.util.Date
  12364. .intersectSpans(l, v, h, g);
  12365. if (e) {
  12366. u = v > g;
  12367. q = s.betweenLesser(l, h, g);
  12368. var z = Math.floor(this.getXYFromDate(q ? l : h)[0]), d = Math
  12369. .floor(this.getXYFromDate(u ? g : v)[0]), f = C ? 0 : d
  12370. - z;
  12371. if (!C && !x) {
  12372. if (u) {
  12373. f += this.parentTaskOffset
  12374. } else {
  12375. f += 2 * this.parentTaskOffset
  12376. }
  12377. }
  12378. b = {
  12379. id : k.internalId,
  12380. leftOffset : C ? (d || z) : z,
  12381. width : Math.max(1, f),
  12382. percentDone : Math.min(k.getPercentDone() || 0, 100)
  12383. };
  12384. o = this.eventRenderer.call(this.eventRendererScope || this, k,
  12385. b, k.store)
  12386. || {};
  12387. var t = this.leftLabelField, j = this.rightLabelField, B;
  12388. if (t) {
  12389. b.leftLabel = t.renderer.call(t.scope || this,
  12390. k.data[t.dataIndex], k)
  12391. }
  12392. if (j) {
  12393. b.rightLabel = j.renderer.call(j.scope || this,
  12394. k.data[j.dataIndex], k)
  12395. }
  12396. Ext.apply(b, o);
  12397. if (C) {
  12398. B = this.milestoneTemplate
  12399. } else {
  12400. b.width = Math.max(1, f);
  12401. var p = "";
  12402. if (u) {
  12403. p = " sch-event-endsoutside "
  12404. }
  12405. if (!q) {
  12406. p = " sch-event-startsoutside "
  12407. }
  12408. b.ctcls = (b.ctcls || "") + p;
  12409. B = this[x ? "eventTemplate" : "parentEventTemplate"]
  12410. }
  12411. var i = " sch-event-resizable-" + k.getResizable();
  12412. if (k.dirty) {
  12413. i += " sch-dirty "
  12414. }
  12415. if (k.isDraggable() === false) {
  12416. i += " sch-event-fixed "
  12417. }
  12418. b.cls = (b.cls || "") + (k.getCls() || "") + i;
  12419. A += B.apply(b)
  12420. }
  12421. }
  12422. if (this.enableBaseline) {
  12423. var r = k.getBaselineStartDate(), a = k.getBaselineEndDate();
  12424. if (!o) {
  12425. o = this.eventRenderer.call(this, k, b, k.store) || {}
  12426. }
  12427. if (r && a) {
  12428. u = a > g;
  12429. q = s.betweenLesser(r, h, g);
  12430. var c = k.isBaselineMilestone(), w = c
  12431. ? this.baselineMilestoneTemplate
  12432. : (k.isLeaf()
  12433. ? this.baselineTaskTemplate
  12434. : this.baselineParentTaskTemplate), m = Math
  12435. .floor(this.getXYFromDate(q ? r : h)[0]), y = c
  12436. ? 0
  12437. : Math.floor(this.getXYFromDate(u ? g : a)[0]) - m;
  12438. A += w.apply({
  12439. basecls : o.basecls || "",
  12440. id : k.internalId + "-base",
  12441. percentDone : k.getBaselinePercentDone(),
  12442. leftOffset : m,
  12443. width : Math.max(1, y)
  12444. })
  12445. }
  12446. }
  12447. return A
  12448. },
  12449. setupTemplates : function() {
  12450. var a = {
  12451. leftLabel : !!this.leftLabelField,
  12452. rightLabel : !!this.rightLabelField,
  12453. prefix : this.eventPrefix,
  12454. enableDependencyDragDrop : this.enableDependencyDragDrop !== false,
  12455. resizeHandles : this.resizeHandles,
  12456. enableProgressBarResize : this.enableProgressBarResize
  12457. };
  12458. if (!this.eventTemplate) {
  12459. a.baseCls = "sch-gantt-task {ctcls}";
  12460. this.eventTemplate = Ext.create("Gnt.template.Task", a)
  12461. }
  12462. if (!this.parentEventTemplate) {
  12463. a.baseCls = "sch-gantt-parent-task {ctcls}";
  12464. this.parentEventTemplate = Ext.create("Gnt.template.ParentTask", a)
  12465. }
  12466. if (!this.milestoneTemplate) {
  12467. a.baseCls = "sch-gantt-milestone {ctcls}";
  12468. this.milestoneTemplate = Ext.create("Gnt.template.Milestone", a)
  12469. }
  12470. if (this.enableBaseline) {
  12471. a = {
  12472. prefix : this.eventPrefix
  12473. };
  12474. if (!this.baselineTaskTemplate) {
  12475. a.baseCls = "sch-gantt-task-baseline sch-gantt-baseline-item {basecls}";
  12476. this.baselineTaskTemplate = Ext.create("Gnt.template.Task", a)
  12477. }
  12478. if (!this.baselineParentTaskTemplate) {
  12479. a.baseCls = "sch-gantt-parenttask-baseline sch-gantt-baseline-item {basecls}";
  12480. this.baselineParentTaskTemplate = Ext.create(
  12481. "Gnt.template.ParentTask", a)
  12482. }
  12483. if (!this.baselineMilestoneTemplate) {
  12484. a.baseCls = "sch-gantt-milestone-baseline sch-gantt-baseline-item {basecls}";
  12485. this.baselineMilestoneTemplate = Ext.create(
  12486. "Gnt.template.Milestone", a)
  12487. }
  12488. }
  12489. },
  12490. getDependencyView : function() {
  12491. return this.dependencyView
  12492. },
  12493. getTaskStore : function() {
  12494. return this.taskStore
  12495. },
  12496. initDependencies : function() {
  12497. if (this.dependencyStore) {
  12498. var b = this, a = Ext.create("Gnt.view.Dependency", Ext.apply({
  12499. containerEl : b.el,
  12500. ganttView : b,
  12501. enableDependencyDragDrop : b.enableDependencyDragDrop,
  12502. store : b.dependencyStore
  12503. }, this.dependencyViewConfig));
  12504. a.on({
  12505. beforednd : b.onBeforeDependencyDrag,
  12506. dndstart : b.onDependencyDragStart,
  12507. drop : b.onDependencyDrop,
  12508. afterdnd : b.onAfterDependencyDragDrop,
  12509. beforecascade : b.onBeforeCascade,
  12510. cascade : b.onCascade,
  12511. scope : b
  12512. });
  12513. b.dependencyView = a;
  12514. b.relayEvents(a, ["dependencydblclick"])
  12515. }
  12516. },
  12517. setupGanttEvents : function() {
  12518. var a = this.getSelectionModel();
  12519. if (this.toggleParentTasksOnClick) {
  12520. this.on({
  12521. taskclick : function(c, b) {
  12522. if (!b.isLeaf()) {
  12523. this.toggle(b)
  12524. }
  12525. },
  12526. scope : this
  12527. })
  12528. }
  12529. },
  12530. configureLabels : function() {
  12531. var c = {
  12532. renderer : function(d) {
  12533. return d
  12534. },
  12535. dataIndex : undefined
  12536. };
  12537. var b = this.leftLabelField;
  12538. if (b) {
  12539. if (Ext.isString(b)) {
  12540. b = this.leftLabelField = {
  12541. dataIndex : b
  12542. }
  12543. }
  12544. Ext.applyIf(b, c);
  12545. if (b.editor) {
  12546. b.editor = Ext.create("Gnt.feature.LabelEditor", this, {
  12547. alignment : "r-r",
  12548. delegate : ".sch-gantt-label-left",
  12549. labelPosition : "left",
  12550. field : b.editor,
  12551. dataIndex : b.dataIndex
  12552. })
  12553. }
  12554. }
  12555. var a = this.rightLabelField;
  12556. if (a) {
  12557. if (Ext.isString(a)) {
  12558. a = this.rightLabelField = {
  12559. dataIndex : a
  12560. }
  12561. }
  12562. Ext.applyIf(a, c);
  12563. if (a.editor) {
  12564. a.editor = Ext.create("Gnt.feature.LabelEditor", this, {
  12565. alignment : "l-l",
  12566. delegate : ".sch-gantt-label-right",
  12567. labelPosition : "right",
  12568. field : a.editor,
  12569. dataIndex : a.dataIndex
  12570. })
  12571. }
  12572. }
  12573. this.on("labeledit_beforestartedit", this.onBeforeLabelEdit, this)
  12574. },
  12575. onBeforeTaskDrag : function(b, a) {
  12576. return !this.readOnly && a.isDraggable() !== false
  12577. && (this.allowParentTaskMove || a.isLeaf())
  12578. },
  12579. onDragDropStart : function() {
  12580. if (this.tip) {
  12581. this.tip.disable()
  12582. }
  12583. },
  12584. onDragDropEnd : function() {
  12585. if (this.tip) {
  12586. this.tip.enable()
  12587. }
  12588. },
  12589. onTaskProgressBarResizeStart : function() {
  12590. if (this.tip) {
  12591. this.tip.hide();
  12592. this.tip.disable()
  12593. }
  12594. },
  12595. onTaskProgressBarResizeEnd : function() {
  12596. if (this.tip) {
  12597. this.tip.enable()
  12598. }
  12599. },
  12600. onTaskResizeStart : function() {
  12601. if (this.tip) {
  12602. this.tip.hide();
  12603. this.tip.disable()
  12604. }
  12605. },
  12606. onTaskResizeEnd : function() {
  12607. if (this.tip) {
  12608. this.tip.enable()
  12609. }
  12610. },
  12611. onBeforeDragCreate : function() {
  12612. return !this.readOnly
  12613. },
  12614. onBeforeTaskResize : function(a, b) {
  12615. return !this.readOnly && b.getSchedulingMode() !== "EffortDriven"
  12616. },
  12617. onBeforeTaskProgressBarResize : function() {
  12618. return !this.readOnly
  12619. },
  12620. onBeforeLabelEdit : function() {
  12621. return !this.readOnly
  12622. },
  12623. onBeforeEdit : function() {
  12624. return !this.readOnly
  12625. },
  12626. beforeRender : function() {
  12627. this.addCls("sch-ganttview");
  12628. this.callParent(arguments)
  12629. },
  12630. afterRender : function() {
  12631. this.initDependencies();
  12632. this.callParent(arguments);
  12633. this.el.on("mousemove", this.configureFeatures, this, {
  12634. single : true
  12635. })
  12636. },
  12637. resolveTaskRecord : function(a) {
  12638. var b = this.findItemByChild(a);
  12639. if (b) {
  12640. return this.getRecord(this.findItemByChild(a))
  12641. }
  12642. return null
  12643. },
  12644. resolveEventRecord : function(a) {
  12645. return this.resolveTaskRecord(a)
  12646. },
  12647. highlightTask : function(b, a) {
  12648. if (!(b instanceof Ext.data.Model)) {
  12649. b = this.taskStore.getById(b)
  12650. }
  12651. if (b) {
  12652. var d = this.getNode(b);
  12653. if (d) {
  12654. Ext.fly(d).addCls("sch-gantt-task-highlighted")
  12655. }
  12656. var c = b.getId() || b.internalId;
  12657. if (a !== false) {
  12658. this.dependencyStore.each(function(e) {
  12659. if (e.getSourceId() == c) {
  12660. this.highlightDependency(e.id);
  12661. this.highlightTask(e.getTargetId(), a)
  12662. }
  12663. }, this)
  12664. }
  12665. }
  12666. },
  12667. unhighlightTask : function(a, c) {
  12668. if (!(a instanceof Ext.data.Model)) {
  12669. a = this.taskStore.getById(a)
  12670. }
  12671. if (a) {
  12672. Ext.fly(this.getNode(a)).removeCls("sch-gantt-task-highlighted");
  12673. var b = a.getId() || a.internalId;
  12674. if (c !== false) {
  12675. this.dependencyStore.each(function(d) {
  12676. if (d.getSourceId() == b) {
  12677. this.unhighlightDependency(d.id);
  12678. this.unhighlightTask(d.getTargetId(), c)
  12679. }
  12680. }, this)
  12681. }
  12682. }
  12683. },
  12684. clearSelectedTasksAndDependencies : function() {
  12685. this.getSelectionModel().deselectAll();
  12686. this.getDependencyView().clearSelectedDependencies();
  12687. this.el.select("tr.sch-gantt-task-highlighted")
  12688. .removeCls("sch-gantt-task-highlighted")
  12689. },
  12690. getCriticalPaths : function() {
  12691. return this.taskStore.getCriticalPaths()
  12692. },
  12693. highlightCriticalPaths : function() {
  12694. this.clearSelectedTasksAndDependencies();
  12695. var g = this.getCriticalPaths(), c = this.getDependencyView(), f = this.dependencyStore, e, d, b, a;
  12696. Ext.each(g, function(h) {
  12697. for (d = 0, b = h.length; d < b; d++) {
  12698. e = h[d];
  12699. this.highlightTask(e, false);
  12700. if (d < (b - 1)) {
  12701. a = f.getAt(f.findBy(function(i) {
  12702. return i.getTargetId() === (e.getId() || e.internalId)
  12703. && i.getSourceId() === (h[d + 1]
  12704. .getId() || h[d + 1].internalId)
  12705. }));
  12706. c.highlightDependency(a)
  12707. }
  12708. }
  12709. }, this);
  12710. this.addCls("sch-gantt-critical-chain");
  12711. this.getSelectionModel().setLocked(true)
  12712. },
  12713. unhighlightCriticalPaths : function() {
  12714. this.el.removeCls("sch-gantt-critical-chain");
  12715. this.getSelectionModel().setLocked(false);
  12716. this.clearSelectedTasksAndDependencies()
  12717. },
  12718. getXOffset : function(a) {
  12719. var b = 0;
  12720. if (a.isMilestone()) {
  12721. b = this.milestoneOffset
  12722. } else {
  12723. if (!a.isLeaf()) {
  12724. b = this.parentTaskOffset
  12725. }
  12726. }
  12727. return b
  12728. },
  12729. onDestroy : function() {
  12730. if (this.dependencyView) {
  12731. this.dependencyView.destroy()
  12732. }
  12733. this.callParent(arguments)
  12734. },
  12735. highlightDependency : function(a) {
  12736. this.dependencyView.highlightDependency(a)
  12737. },
  12738. unhighlightDependency : function(a) {
  12739. this.dependencyView.unhighlightDependency(a)
  12740. },
  12741. onBeforeDependencyDrag : function(b, a) {
  12742. return this.fireEvent("beforedependencydrag", this, a)
  12743. },
  12744. onDependencyDragStart : function(a) {
  12745. this.fireEvent("dependencydragstart", this);
  12746. if (this.tip) {
  12747. this.tip.disable()
  12748. }
  12749. },
  12750. onDependencyDrop : function(b, c, a, d) {
  12751. this.fireEvent("dependencydrop", this, this.taskStore.getNodeById(c),
  12752. this.taskStore.getById(a), d)
  12753. },
  12754. onAfterDependencyDragDrop : function() {
  12755. this.fireEvent("afterdependencydragdrop", this);
  12756. if (this.tip) {
  12757. this.tip.enable()
  12758. }
  12759. },
  12760. onBeforeCascade : function(a, b) {
  12761. this.taskStore.un("update", this.onUpdate, this)
  12762. },
  12763. onCascade : function(a, b) {
  12764. this.taskStore.on("update", this.onUpdate, this)
  12765. },
  12766. onUpdate : function(c, a, b, d) {
  12767. if (d && d.length === 1 && d[0] === "expanded") {
  12768. return
  12769. }
  12770. this.callParent(arguments)
  12771. },
  12772. getLeftEditor : function() {
  12773. return this.leftLabelField.editor
  12774. },
  12775. getRightEditor : function() {
  12776. return this.rightLabelField.editor
  12777. },
  12778. editLeftLabel : function(a) {
  12779. var b = this.leftLabelField && this.getLeftEditor();
  12780. if (b) {
  12781. b.edit(a)
  12782. }
  12783. },
  12784. editRightLabel : function(a) {
  12785. var b = this.rightLabelField && this.getRightEditor();
  12786. if (b) {
  12787. b.edit(a)
  12788. }
  12789. },
  12790. getOuterElementFromEventRecord : function(a) {
  12791. var b = this.callParent([a]);
  12792. return b && b.up(this.eventWrapSelector) || null
  12793. },
  12794. getDependenciesForTask : function(a) {
  12795. console
  12796. .warn("`ganttPanel.getDependenciesForTask()` is deprecated, use `task.getAllDependencies()` instead");
  12797. return a.getAllDependencies()
  12798. },
  12799. setNewTemplate : function() {
  12800. var b = this, a = b.headerCt.getColumnsForTpl(true);
  12801. b.tpl = b.getTableChunker().getTableTpl({
  12802. columns : [a[0]],
  12803. features : b.features
  12804. })
  12805. },
  12806. onAdd : function() {
  12807. Ext.suspendLayouts();
  12808. this.callParent(arguments);
  12809. Ext.resumeLayouts()
  12810. },
  12811. onRemove : function() {
  12812. Ext.suspendLayouts();
  12813. this.callParent(arguments);
  12814. Ext.resumeLayouts()
  12815. }
  12816. });
  12817. Ext.define("Gnt.panel.Gantt", {
  12818. extend : "Sch.panel.TimelineTreePanel",
  12819. alias : ["widget.ganttpanel"],
  12820. alternateClassName : ["Sch.gantt.GanttPanel"],
  12821. requires : ["Gnt.view.Gantt", "Gnt.model.Dependency",
  12822. "Gnt.data.ResourceStore", "Gnt.data.AssignmentStore",
  12823. "Gnt.feature.WorkingTime", "Gnt.data.Calendar",
  12824. "Gnt.data.TaskStore", "Gnt.data.DependencyStore"],
  12825. uses : ["Sch.plugin.CurrentTimeLine"],
  12826. lockedXType : "treepanel",
  12827. normalXType : "ganttpanel",
  12828. viewType : "ganttview",
  12829. syncRowHeight : false,
  12830. layout : "border",
  12831. lightWeight : true,
  12832. leftLabelField : null,
  12833. rightLabelField : null,
  12834. highlightWeekends : true,
  12835. weekendsAreWorkdays : false,
  12836. skipWeekendsDuringDragDrop : true,
  12837. enableTaskDragDrop : true,
  12838. enableDependencyDragDrop : true,
  12839. enableProgressBarResize : false,
  12840. toggleParentTasksOnClick : true,
  12841. addRowOnTab : true,
  12842. recalculateParents : true,
  12843. cascadeChanges : false,
  12844. showTodayLine : false,
  12845. enableBaseline : false,
  12846. baselineVisible : false,
  12847. enableAnimations : false,
  12848. workingTimePlugin : null,
  12849. todayLinePlugin : null,
  12850. allowParentTaskMove : false,
  12851. enableDragCreation : true,
  12852. eventRenderer : Ext.emptyFn,
  12853. eventRendererScope : null,
  12854. eventTemplate : null,
  12855. parentEventTemplate : null,
  12856. milestoneTemplate : null,
  12857. autoHeight : null,
  12858. calendar : null,
  12859. taskStore : null,
  12860. dependencyStore : null,
  12861. resourceStore : null,
  12862. assignmentStore : null,
  12863. columnLines : true,
  12864. dndValidatorFn : Ext.emptyFn,
  12865. createValidatorFn : Ext.emptyFn,
  12866. resizeHandles : "both",
  12867. resizeValidatorFn : Ext.emptyFn,
  12868. resizeConfig : null,
  12869. progressBarResizeConfig : null,
  12870. dragDropConfig : null,
  12871. createConfig : null,
  12872. refreshLockedTreeOnDependencyUpdate : false,
  12873. initStores : function() {
  12874. var a = Ext.StoreMgr.lookup(this.taskStore || this.store);
  12875. if (!a) {
  12876. Ext.Error.raise("You must specify a taskStore config")
  12877. }
  12878. if (!(a instanceof Gnt.data.TaskStore)) {
  12879. Ext.Error
  12880. .raise("A `taskStore` should be an instance of `Gnt.data.TaskStore` (or of a subclass)")
  12881. }
  12882. Ext.apply(this, {
  12883. store : a,
  12884. taskStore : a
  12885. });
  12886. var d = this.calendar = a.calendar;
  12887. if (this.needToTranslateOption("weekendsAreWorkdays")) {
  12888. d.setWeekendsAreWorkDays(this.weekendsAreWorkdays)
  12889. }
  12890. if (a.dependencyStore) {
  12891. this.dependencyStore = a.dependencyStore
  12892. } else {
  12893. if (this.dependencyStore) {
  12894. this.dependencyStore = Ext.StoreMgr
  12895. .lookup(this.dependencyStore);
  12896. a.setDependencyStore(this.dependencyStore)
  12897. } else {
  12898. this.dependencyStore = Ext.create("Gnt.data.DependencyStore");
  12899. a.setDependencyStore(this.dependencyStore)
  12900. }
  12901. }
  12902. if (!(this.dependencyStore instanceof Gnt.data.DependencyStore)) {
  12903. Ext.Error
  12904. .raise("The Gantt dependency store should be a Gnt.data.DependencyStore, or a subclass thereof.")
  12905. }
  12906. var b;
  12907. if (a.getResourceStore()) {
  12908. b = a.getResourceStore()
  12909. } else {
  12910. if (this.resourceStore) {
  12911. b = Ext.StoreMgr.lookup(this.resourceStore)
  12912. } else {
  12913. b = Ext.create("Gnt.data.ResourceStore")
  12914. }
  12915. }
  12916. if (!(b instanceof Gnt.data.ResourceStore)) {
  12917. Ext.Error
  12918. .raise("A `ResourceStore` should be an instance of `Gnt.data.ResourceStore` (or of a subclass)")
  12919. }
  12920. var c;
  12921. if (a.getAssignmentStore()) {
  12922. c = a.getAssignmentStore()
  12923. } else {
  12924. if (this.assignmentStore) {
  12925. c = Ext.StoreMgr.lookup(this.assignmentStore)
  12926. } else {
  12927. c = Ext.create("Gnt.data.AssignmentStore")
  12928. }
  12929. }
  12930. if (!(c instanceof Gnt.data.AssignmentStore)) {
  12931. Ext.Error
  12932. .raise("An `assignmentStore` should be an instance of `Gnt.data.AssignmentStore` (or of a subclass)")
  12933. }
  12934. if (this.lockable) {
  12935. this.bindAssignmentStore(c, true);
  12936. this.bindResourceStore(b, true)
  12937. }
  12938. },
  12939. initComponent : function() {
  12940. if (Ext.isBoolean(this.showBaseline)) {
  12941. this.enableBaseline = this.baselineVisible = this.showBaseline;
  12942. this.showBaseline = Gnt.panel.Gantt.prototype.showBaseline
  12943. }
  12944. this.autoHeight = false;
  12945. this.initStores();
  12946. if (this.needToTranslateOption("cascadeChanges")) {
  12947. this.setCascadeChanges(this.cascadeChanges)
  12948. }
  12949. if (this.needToTranslateOption("recalculateParents")) {
  12950. this.setRecalculateParents(this.recalculateParents)
  12951. }
  12952. if (this.needToTranslateOption("skipWeekendsDuringDragDrop")) {
  12953. this.setSkipWeekendsDuringDragDrop(this.skipWeekendsDuringDragDrop)
  12954. }
  12955. if (this.lockable) {
  12956. this.lockedGridConfig = this.lockedGridConfig || {};
  12957. Ext.apply(this.lockedGridConfig, {
  12958. columnLines : true,
  12959. rowLines : true
  12960. });
  12961. this.configureFunctionality();
  12962. this.mon(this.taskStore, "beforecascade", function(e) {
  12963. var d = this.normalGrid.getView().store;
  12964. d.suspendEvents()
  12965. }, this);
  12966. this.mon(this.taskStore, "cascade", function(h, d) {
  12967. var g = this.normalGrid.getView().store;
  12968. g.resumeEvents();
  12969. if (d.nbrAffected > 0) {
  12970. var e = this.normalGrid.getView();
  12971. var f = this.lockedGrid.getView();
  12972. e.refreshKeepingScroll(true);
  12973. setTimeout(function() {
  12974. f.saveScrollState();
  12975. f.refresh();
  12976. f.restoreScrollState()
  12977. }, 0)
  12978. }
  12979. }, this);
  12980. this.mon(this.taskStore, "refresh", function() {
  12981. this.getSchedulingView().refreshKeepingScroll(true);
  12982. if (Ext.versions.extjs.isLessThan("4.1.2")) {
  12983. var e = this.getSchedulingView().selModel.selected, f = this, d;
  12984. e.each(function(g) {
  12985. d = f.getSchedulingView().store.indexOfId(g
  12986. .getId());
  12987. f.getSchedulingView().onRowSelect(d);
  12988. f.view.lockedView.onRowSelect(d)
  12989. })
  12990. }
  12991. }, this)
  12992. }
  12993. this.callParent(arguments);
  12994. var a = this.getSchedulingView();
  12995. this.relayEvents(a, ["taskclick", "taskdblclick", "taskcontextmenu",
  12996. "beforetaskresize", "taskresizestart",
  12997. "partialtaskresize", "aftertaskresize",
  12998. "beforeprogressbarresize", "progressbarresizestart",
  12999. "afterprogressbarresize", "beforetaskdrag",
  13000. "taskdragstart", "taskdrop", "aftertaskdrop",
  13001. "labeledit_beforestartedit",
  13002. "labeledit_beforecomplete", "labeledit_complete",
  13003. "beforedependencydrag", "dependencydragstart",
  13004. "dependencydrop", "afterdependencydragdrop",
  13005. "dependencydblclick", "beforedragcreate",
  13006. "dragcreatestart", "dragcreateend", "afterdragcreate"]);
  13007. if (this.lockable) {
  13008. this.bodyCls = (this.bodyCls || "")
  13009. + " sch-ganttpanel-container-body";
  13010. a.store.calendar = this.calendar;
  13011. this.fixSelectionModel();
  13012. if (this.addRowOnTab) {
  13013. var b = this.lockedGrid, c = this.getSelectionModel();
  13014. c.onEditorTab = Ext.Function.createInterceptor(c.onEditorTab,
  13015. function(h, i) {
  13016. var g = b.view, f = h.getActiveRecord(), j = h
  13017. .getActiveColumn(), d = g.getPosition(f, j);
  13018. if (!i.shiftKey
  13019. && d.column === b.headerCt.getColumnCount()
  13020. - 1
  13021. && d.row === b.view.store.getCount() - 1) {
  13022. f.addTaskBelow({
  13023. leaf : true
  13024. })
  13025. }
  13026. })
  13027. }
  13028. }
  13029. },
  13030. needToTranslateOption : function(a) {
  13031. return this.hasOwnProperty(a) || this.self.prototype.hasOwnProperty(a)
  13032. && this.self != Gnt.panel.Gantt
  13033. },
  13034. fixSelectionModel : function() {
  13035. var a = this.getSelectionModel();
  13036. var d = this.lockedGrid.getView();
  13037. var c = this.normalGrid.getView();
  13038. d.__lockedType = "locked";
  13039. c.__lockedType = "normal";
  13040. var e = d.onAdd;
  13041. d.onAdd = function() {
  13042. a.__preventUpdateOf = "normal";
  13043. e.apply(this, arguments);
  13044. delete a.__preventUpdateOf
  13045. };
  13046. var b = c.onAdd;
  13047. c.onAdd = function() {
  13048. a.__preventUpdateOf = "locked";
  13049. b.apply(this, arguments);
  13050. delete a.__preventUpdateOf
  13051. };
  13052. var f = d.store;
  13053. d.bindStore(null);
  13054. c.bindStore(null);
  13055. d.bindStore(f);
  13056. c.bindStore(f);
  13057. Ext.apply(a, {
  13058. onSelectChange : function(m, j, q, g) {
  13059. var o = this, r = o.views, k = r.length, p = o.store, h = p
  13060. .indexOf(m), n = j ? "select" : "deselect", l = 0;
  13061. if ((q || o.fireEvent("before" + n, o, m, h)) !== false
  13062. && g() !== false) {
  13063. for (; l < k; l++) {
  13064. if (!this.__preventUpdateOf
  13065. || r[l].__lockedType != this.__preventUpdateOf) {
  13066. if (j) {
  13067. r[l].onRowSelect(h, q)
  13068. } else {
  13069. r[l].onRowDeselect(h, q)
  13070. }
  13071. }
  13072. }
  13073. if (!q) {
  13074. o.fireEvent(n, o, m, h)
  13075. }
  13076. }
  13077. }
  13078. })
  13079. },
  13080. getDependencyView : function() {
  13081. return this.getSchedulingView().getDependencyView()
  13082. },
  13083. disableWeekendHighlighting : function(a) {
  13084. this.workingTimePlugin.setDisabled(a)
  13085. },
  13086. resolveTaskRecord : function(a) {
  13087. return this.getSchedulingView().resolveTaskRecord(a)
  13088. },
  13089. fitTimeColumns : function() {
  13090. this.getSchedulingView().fitColumns()
  13091. },
  13092. getResourceStore : function() {
  13093. return this.getTaskStore().getResourceStore()
  13094. },
  13095. getAssignmentStore : function() {
  13096. return this.getTaskStore().getAssignmentStore()
  13097. },
  13098. getTaskStore : function() {
  13099. return this.taskStore
  13100. },
  13101. getDependencyStore : function() {
  13102. return this.dependencyStore
  13103. },
  13104. onDragDropStart : function() {
  13105. if (this.tip) {
  13106. this.tip.hide();
  13107. this.tip.disable()
  13108. }
  13109. },
  13110. onDragDropEnd : function() {
  13111. if (this.tip) {
  13112. this.tip.enable()
  13113. }
  13114. },
  13115. configureFunctionality : function() {
  13116. var a = this.plugins = [].concat(this.plugins || []);
  13117. if (this.highlightWeekends) {
  13118. this.workingTimePlugin = Ext.create("Gnt.feature.WorkingTime", {
  13119. calendar : this.calendar
  13120. });
  13121. a.push(this.workingTimePlugin)
  13122. }
  13123. if (this.showTodayLine) {
  13124. this.todayLinePlugin = new Sch.plugin.CurrentTimeLine();
  13125. a.push(this.todayLinePlugin)
  13126. }
  13127. },
  13128. getWorkingTimePlugin : function() {
  13129. return this.workingTimePlugin
  13130. },
  13131. beforeRender : function() {
  13132. if (this.lockable) {
  13133. var a = " sch-ganttpanel sch-horizontal ";
  13134. if (this.highlightWeekends) {
  13135. a += " sch-ganttpanel-highlightweekends "
  13136. }
  13137. this.addCls(a);
  13138. if (this.baselineVisible) {
  13139. this.showBaseline()
  13140. }
  13141. }
  13142. this.callParent(arguments)
  13143. },
  13144. updateDependencyTasks : function(b) {
  13145. var a = b.getSourceTask(this.taskStore);
  13146. var c = b.getTargetTask(this.taskStore);
  13147. var d = this.lockedGrid.getView();
  13148. if (a) {
  13149. d.onUpdate(d.store, a)
  13150. }
  13151. if (c) {
  13152. d.onUpdate(d.store, c)
  13153. }
  13154. },
  13155. registerLockedDependencyListeners : function() {
  13156. var c = this;
  13157. var a = this.getDependencyStore();
  13158. var b = {
  13159. load : function() {
  13160. c.lockedGrid.getView().refresh()
  13161. },
  13162. add : function(e, d) {
  13163. for (var f = 0; f < d.length; f++) {
  13164. c.updateDependencyTasks(d[f])
  13165. }
  13166. },
  13167. update : function(e, d) {
  13168. c.updateDependencyTasks(d)
  13169. },
  13170. remove : function(e, d) {
  13171. c.updateDependencyTasks(d)
  13172. }
  13173. };
  13174. a.un(b);
  13175. a.on(b)
  13176. },
  13177. afterRender : function() {
  13178. this.callParent(arguments);
  13179. if (this.lockable) {
  13180. this.applyPatches()
  13181. }
  13182. },
  13183. showBaseline : function() {
  13184. this.addCls("sch-ganttpanel-showbaseline")
  13185. },
  13186. hideBaseline : function() {
  13187. this.removeCls("sch-ganttpanel-showbaseline")
  13188. },
  13189. toggleBaseline : function() {
  13190. this.toggleCls("sch-ganttpanel-showbaseline")
  13191. },
  13192. zoomToFit : function() {
  13193. var a = this.taskStore.getTotalTimeSpan();
  13194. if (a.start && a.end && a.start < a.end) {
  13195. this.setTimeSpan(a.start, a.end);
  13196. this.fitTimeColumns()
  13197. }
  13198. },
  13199. getCascadeChanges : function() {
  13200. return this.taskStore.cascadeChanges
  13201. },
  13202. setCascadeChanges : function(a) {
  13203. this.taskStore.cascadeChanges = a
  13204. },
  13205. getRecalculateParents : function() {
  13206. return this.taskStore.recalculateParents
  13207. },
  13208. setRecalculateParents : function(a) {
  13209. this.taskStore.recalculateParents = a
  13210. },
  13211. setSkipWeekendsDuringDragDrop : function(a) {
  13212. this.taskStore.skipWeekendsDuringDragDrop = this.skipWeekendsDuringDragDrop = a
  13213. },
  13214. getSkipWeekendsDuringDragDrop : function() {
  13215. return this.taskStore.skipWeekendsDuringDragDrop
  13216. },
  13217. applyPatches : function() {
  13218. if (Ext.tree.plugin && Ext.tree.plugin.TreeViewDragDrop) {
  13219. var a;
  13220. Ext.each(this.lockedGrid.getView().plugins, function(b) {
  13221. if (b instanceof Ext.tree.plugin.TreeViewDragDrop) {
  13222. a = b;
  13223. return false
  13224. }
  13225. });
  13226. if (!a || !a.dropZone) {
  13227. return
  13228. }
  13229. a.dropZone.handleNodeDrop = function(e, l, f) {
  13230. var n = this, o = n.view, g = l.parentNode, p = o.getStore(), r = [], b, d, k, c, j, m, q, h;
  13231. if (e.copy) {
  13232. b = e.records;
  13233. e.records = [];
  13234. for (d = 0, k = b.length; d < k; d++) {
  13235. e.records.push(Ext.apply({}, b[d].data))
  13236. }
  13237. }
  13238. n.cancelExpand();
  13239. if (f == "before") {
  13240. c = g.insertBefore;
  13241. j = [null, l];
  13242. l = g
  13243. } else {
  13244. if (f == "after") {
  13245. if (l.nextSibling) {
  13246. c = g.insertBefore;
  13247. j = [null, l.nextSibling]
  13248. } else {
  13249. c = g.appendChild;
  13250. j = [null]
  13251. }
  13252. l = g
  13253. } else {
  13254. if (!l.isExpanded()) {
  13255. m = true
  13256. }
  13257. c = l.appendChild;
  13258. j = [null]
  13259. }
  13260. }
  13261. q = function() {
  13262. var i;
  13263. for (d = 0, k = e.records.length; d < k; d++) {
  13264. j[0] = e.records[d];
  13265. j[0].isMove = true;
  13266. i = c.apply(l, j);
  13267. delete j[0].isMove;
  13268. if (Ext.enableFx && n.dropHighlight) {
  13269. r.push(o.getNode(i))
  13270. }
  13271. }
  13272. if (Ext.enableFx && n.dropHighlight) {
  13273. Ext.Array.forEach(r, function(s) {
  13274. if (s) {
  13275. Ext
  13276. .fly(s.firstChild
  13277. ? s.firstChild
  13278. : s)
  13279. .highlight(n.dropHighlightColor)
  13280. }
  13281. })
  13282. }
  13283. };
  13284. if (m) {
  13285. l.expand(false, q)
  13286. } else {
  13287. q()
  13288. }
  13289. }
  13290. }
  13291. },
  13292. bindResourceStore : function(c, a) {
  13293. var b = this;
  13294. if (!a && b.resourceStore) {
  13295. if (c !== b.resourceStore && b.resourceStore.autoDestroy) {
  13296. b.resourceStore.destroy()
  13297. } else {
  13298. b.mun(b.resourceStore, {
  13299. scope : b,
  13300. datachanged : b.onResourceStoreDataChanged
  13301. })
  13302. }
  13303. if (!c) {
  13304. b.resourceStore = null
  13305. }
  13306. }
  13307. if (c) {
  13308. c = Ext.data.StoreManager.lookup(c);
  13309. b.mon(c, {
  13310. scope : b,
  13311. datachanged : b.onResourceStoreDataChanged
  13312. });
  13313. this.taskStore.setResourceStore(c)
  13314. }
  13315. b.resourceStore = c;
  13316. if (c && !a) {
  13317. b.getView().refreshKeepingScroll()
  13318. }
  13319. },
  13320. bindAssignmentStore : function(c, a) {
  13321. var b = this;
  13322. if (!a && b.assignmentStore) {
  13323. if (c !== b.assignmentStore && b.assignmentStore.autoDestroy) {
  13324. b.assignmentStore.destroy()
  13325. } else {
  13326. b.mun(b.assignmentStore, {
  13327. scope : b,
  13328. datachanged : b.onAssignmentStoreDataChanged
  13329. })
  13330. }
  13331. if (!c) {
  13332. b.assignmentStore = null
  13333. }
  13334. }
  13335. if (c) {
  13336. c = Ext.data.StoreManager.lookup(c);
  13337. b.mon(c, {
  13338. scope : b,
  13339. datachanged : b.onAssignmentStoreDataChanged
  13340. });
  13341. this.taskStore.setAssignmentStore(c)
  13342. }
  13343. b.assignmentStore = c;
  13344. if (c && !a) {
  13345. b.getView().refreshKeepingScroll()
  13346. }
  13347. },
  13348. onResourceStoreDataChanged : function() {
  13349. this.getView().refreshKeepingScroll()
  13350. },
  13351. onAssignmentStoreDataChanged : function() {
  13352. this.getView().refreshKeepingScroll()
  13353. },
  13354. expandAll : function() {
  13355. Ext.suspendLayouts();
  13356. this.callParent(arguments);
  13357. Ext.resumeLayouts()
  13358. },
  13359. collapseAll : function() {
  13360. Ext.suspendLayouts();
  13361. this.callParent(arguments);
  13362. Ext.resumeLayouts()
  13363. }
  13364. });
  13365. Ext.define("Gnt.column.EndDate", {
  13366. extend : "Ext.grid.column.Date",
  13367. alias : "widget.enddatecolumn",
  13368. requires : ["Ext.grid.CellEditor"],
  13369. text : "Finish",
  13370. width : 100,
  13371. align : "left",
  13372. task : null,
  13373. editorFormat : null,
  13374. adjustMilestones : true,
  13375. constructor : function(a) {
  13376. a = a || {};
  13377. var b = a.field || a.editor;
  13378. delete a.field;
  13379. delete a.editor;
  13380. this.field = Ext.create("Ext.grid.CellEditor", {
  13381. ignoreNoChange : true,
  13382. field : b || {
  13383. xtype : "datefield",
  13384. format : a.editorFormat || a.format || this.format
  13385. || Ext.Date.defaultFormat
  13386. },
  13387. listeners : {
  13388. beforecomplete : this.onBeforeEditComplete,
  13389. scope : this
  13390. }
  13391. });
  13392. this.callParent([a]);
  13393. this.scope = this;
  13394. this.renderer = a.renderer || this.rendererFunc;
  13395. this.editorFormat = this.editorFormat || this.format
  13396. },
  13397. beforeRender : function() {
  13398. if (!this.dataIndex) {
  13399. var a = this.up("treepanel");
  13400. this.dataIndex = a.store.model.prototype.endDateField
  13401. }
  13402. this.callParent(arguments)
  13403. },
  13404. rendererFunc : function(c, d, b) {
  13405. if (!c) {
  13406. return
  13407. }
  13408. if (!b.isEditable(this.dataIndex)) {
  13409. d.tdCls = (d.tdCls || "") + " sch-column-readonly"
  13410. }
  13411. var a = c && b.getStartDate() - c === 0;
  13412. if ((!a || this.adjustMilestones)
  13413. && c - Ext.Date.clearTime(c, true) === 0
  13414. && !Ext.Date.formatContainsHourInfo(this.format)) {
  13415. c = Sch.util.Date.add(c, Sch.util.Date.MILLI, -1)
  13416. }
  13417. return Ext.util.Format.date(c, this.format)
  13418. },
  13419. afterRender : function() {
  13420. this.callParent(arguments);
  13421. var a = this.ownerCt.up("treepanel");
  13422. a.on({
  13423. edit : this.onTreeEdit,
  13424. beforeedit : this.onBeforeTreeEdit,
  13425. scope : this
  13426. })
  13427. },
  13428. onBeforeTreeEdit : function(c) {
  13429. if (c.column === this) {
  13430. c.doNotUpdateRecord = true;
  13431. var b = this.task = c.record;
  13432. if (!b.isEditable(this.dataIndex)) {
  13433. return false
  13434. }
  13435. var d = c.value;
  13436. var a = d && b.getStartDate() - d === 0;
  13437. if (d) {
  13438. if ((!a || this.adjustMilestones)
  13439. && d - Ext.Date.clearTime(d, true) === 0
  13440. && !Ext.Date.formatContainsHourInfo(this.editorFormat)) {
  13441. d = Sch.util.Date.add(d, Sch.util.Date.MILLI, -1)
  13442. }
  13443. c.value = Ext.Date.parse(Ext.Date.format(d, this.editorFormat),
  13444. this.editorFormat)
  13445. }
  13446. }
  13447. },
  13448. onBeforeEditComplete : function(d, e, b) {
  13449. var f = Ext.Date.formatContainsHourInfo(this.editorFormat);
  13450. var a = this.task.getStartDate();
  13451. var c = b && a - b === 0;
  13452. if ((!c || this.adjustMilestones) && e && b
  13453. && b - Ext.Date.clearTime(b, true) === 0 && !f) {
  13454. e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1);
  13455. return e >= this.task.getStartDate()
  13456. }
  13457. },
  13458. onTreeEdit : function(c, b) {
  13459. if (b.column === this) {
  13460. if (b.value) {
  13461. var a = b.record;
  13462. var d = b.value;
  13463. if (!Ext.Date.formatContainsHourInfo(this.editorFormat)) {
  13464. d = a.getCalendar().getCalendarDay(d)
  13465. .getAvailabilityEndFor(d)
  13466. || d
  13467. }
  13468. b.record.setEndDate(d, false)
  13469. } else {
  13470. b.record.setEndDate(null)
  13471. }
  13472. }
  13473. }
  13474. });
  13475. Ext.define("Gnt.column.PercentDone", {
  13476. extend : "Ext.grid.column.Number",
  13477. alias : "widget.percentdonecolumn",
  13478. text : "% Done",
  13479. width : 50,
  13480. format : "0",
  13481. align : "center",
  13482. field : {
  13483. xtype : "numberfield",
  13484. minValue : 0,
  13485. maxValue : 100
  13486. },
  13487. beforeRender : function() {
  13488. if (!this.dataIndex) {
  13489. var a = this.up("treepanel");
  13490. this.dataIndex = a.store.model.prototype.percentDoneField
  13491. }
  13492. this.callParent(arguments)
  13493. }
  13494. });
  13495. Ext.define("Gnt.column.StartDate", {
  13496. extend : "Ext.grid.column.Date",
  13497. alias : "widget.startdatecolumn",
  13498. text : "Start",
  13499. width : 100,
  13500. align : "left",
  13501. editorFormat : null,
  13502. adjustMilestones : true,
  13503. constructor : function(a) {
  13504. a = a || {};
  13505. var b = a.field || a.editor;
  13506. delete a.field;
  13507. delete a.editor;
  13508. this.field = Ext.create("Ext.grid.CellEditor", {
  13509. ignoreNoChange : true,
  13510. field : b || {
  13511. xtype : "datefield",
  13512. format : a.editorFormat || a.format
  13513. || this.format
  13514. || Ext.Date.defaultFormat
  13515. }
  13516. });
  13517. this.hasCustomRenderer = true;
  13518. this.callParent([a]);
  13519. this.renderer = a.renderer || this.rendererFunc;
  13520. this.editorFormat = this.editorFormat || this.format
  13521. },
  13522. beforeRender : function() {
  13523. var a = this.up("treepanel");
  13524. if (!this.dataIndex) {
  13525. this.dataIndex = a.store.model.prototype.startDateField
  13526. }
  13527. this.callParent(arguments);
  13528. a.on({
  13529. edit : this.onTreeEdit,
  13530. beforeedit : this.onBeforeTreeEdit,
  13531. scope : this
  13532. })
  13533. },
  13534. rendererFunc : function(a, d, b) {
  13535. if (!a) {
  13536. return
  13537. }
  13538. if (!b.isEditable(this.dataIndex)) {
  13539. d.tdCls = (d.tdCls || "") + " sch-column-readonly"
  13540. }
  13541. var c = b.getEndDate();
  13542. if (this.adjustMilestones && c - a === 0
  13543. && a - Ext.Date.clearTime(a, true) === 0
  13544. && !Ext.Date.formatContainsHourInfo(this.format)) {
  13545. a = Sch.util.Date.add(a, Sch.util.Date.MILLI, -1)
  13546. }
  13547. return Ext.util.Format.date(a, this.format)
  13548. },
  13549. onBeforeTreeEdit : function(c) {
  13550. if (c.column == this) {
  13551. c.doNotUpdateRecord = true;
  13552. var b = c.record;
  13553. if (!b.isEditable(this.dataIndex)) {
  13554. return false
  13555. }
  13556. var a = c.value;
  13557. if (a) {
  13558. if (this.adjustMilestones
  13559. && b.getEndDate() - b.getStartDate() === 0
  13560. && a - Ext.Date.clearTime(a, true) === 0) {
  13561. a = Sch.util.Date.add(a, Sch.util.Date.MILLI, -1)
  13562. }
  13563. c.originalEditorValue = c.value = Ext.Date.parse(
  13564. Ext.Date.format(a, this.editorFormat),
  13565. this.editorFormat)
  13566. }
  13567. }
  13568. },
  13569. onTreeEdit : function(d, c) {
  13570. var b = c.record;
  13571. var e = c.value;
  13572. var a = c.originalValue;
  13573. if (c.column == this) {
  13574. if (!e) {
  13575. b.setStartDate(null)
  13576. } else {
  13577. if (e - c.originalEditorValue !== 0) {
  13578. var f = b.getEndDate();
  13579. if (this.adjustMilestones && f
  13580. && f - b.getStartDate() === 0
  13581. && a - Ext.Date.clearTime(a, true) === 0
  13582. && e - Ext.Date.clearTime(e, true) === 0) {
  13583. e = b.getCalendar().getCalendarDay(e)
  13584. .getAvailabilityEndFor(e)
  13585. || e
  13586. }
  13587. b
  13588. .setStartDate(
  13589. e,
  13590. true,
  13591. b.getTaskStore().skipWeekendsDuringDragDrop)
  13592. }
  13593. }
  13594. }
  13595. }
  13596. });
  13597. Ext.define("Gnt.column.WBS", {
  13598. extend : "Ext.grid.column.Column",
  13599. alias : "widget.wbscolumn",
  13600. text : "#",
  13601. width : 40,
  13602. align : "left",
  13603. dataIndex : "index",
  13604. renderer : function(f, g, b, h, d, e) {
  13605. var a = e.getRootNode(), c = [];
  13606. while (b !== a) {
  13607. c.push(b.data.index + 1);
  13608. b = b.parentNode
  13609. }
  13610. return c.reverse().join(".")
  13611. }
  13612. });
  13613. Ext.define("Gnt.column.SchedulingMode", {
  13614. extend : "Ext.grid.column.Column",
  13615. alias : "widget.schedulingmodecolumn",
  13616. text : "Mode",
  13617. width : 100,
  13618. align : "left",
  13619. data : [["FixedDuration", "Fixed duration"],
  13620. ["EffortDriven", "Effort driven"],
  13621. ["DynamicAssignment", "Dynamic assignment"],
  13622. ["Manual", "Manual"], ["Normal", "Normal"]],
  13623. modeNames : null,
  13624. pickerAlign : "tl-bl?",
  13625. matchFieldWidth : true,
  13626. constructor : function(a) {
  13627. a = a || {};
  13628. var c = a.field || a.editor;
  13629. a.field = c || {
  13630. xtype : "combo",
  13631. editable : false,
  13632. store : this.data,
  13633. pickerAlign : this.pickerAlign,
  13634. matchFieldWidth : this.matchFieldWidth
  13635. };
  13636. var b = this.modeNames = {};
  13637. Ext.Array.each(this.data, function(d) {
  13638. b[d[0]] = d[1]
  13639. });
  13640. this.scope = this;
  13641. this.callParent([a])
  13642. },
  13643. beforeRender : function() {
  13644. if (!this.dataIndex) {
  13645. var a = this.up("treepanel");
  13646. this.dataIndex = a.store.model.prototype.schedulingModeField
  13647. }
  13648. this.callParent(arguments)
  13649. },
  13650. renderer : function(a) {
  13651. return this.modeNames[a]
  13652. },
  13653. afterRender : function() {
  13654. this.callParent(arguments);
  13655. this.tree = this.ownerCt.up("treepanel");
  13656. this.tree.on("edit", this.onTreeEdit, this)
  13657. },
  13658. onTreeEdit : function(b, a) {
  13659. if (a.column == this) {
  13660. a.record.setSchedulingMode(a.value)
  13661. }
  13662. }
  13663. });
  13664. Ext.define("Gnt.column.ResourceAssignment", {
  13665. extend : "Ext.grid.column.Column",
  13666. alias : "widget.resourceassignmentcolumn",
  13667. text : "Assigned Resources",
  13668. tdCls : "sch-assignment-cell",
  13669. showUnits : true,
  13670. assignmentStore : null,
  13671. initComponent : function() {
  13672. this.formatString = "{0}" + (this.showUnits ? " [{1}%]" : "");
  13673. this.callParent(arguments)
  13674. },
  13675. afterRender : function() {
  13676. this.scope = this;
  13677. this.callParent(arguments);
  13678. this.assignmentStore = this.getOwnerHeaderCt().up("ganttpanel").assignmentStore
  13679. },
  13680. renderer : function(k, o, b, h, n, m, j) {
  13681. var g = [], e = this.assignmentStore, a, f = b.getInternalId();
  13682. if (e.resourceStore.getCount() > 0) {
  13683. for (var d = 0, c = e.getCount(); d < c; d++) {
  13684. a = e.getAt(d);
  13685. if (a.getTaskId() === f) {
  13686. g.push(Ext.String.format(this.formatString, a
  13687. .getResourceName(), a.getUnits()))
  13688. }
  13689. }
  13690. return g.join(", ")
  13691. }
  13692. }
  13693. });
  13694. Ext.define("Gnt.column.ResourceName", {
  13695. extend : "Ext.grid.column.Column",
  13696. alias : "widget.resourcenamecolumn",
  13697. header : "资源名称",
  13698. dataIndex : "ResourceName",
  13699. flex : 1,
  13700. align : "left"
  13701. });
  13702. Ext.define("Gnt.column.AssignmentUnits", {
  13703. extend : "Ext.grid.column.Number",
  13704. alias : "widget.assignmentunitscolumn",
  13705. text : "分配比率",
  13706. dataIndex : "Units",
  13707. format : "0 %",
  13708. align : "left"
  13709. });
  13710. Ext.define("Gnt.widget.AssignmentGrid", {
  13711. requires : ["Gnt.model.Resource", "Gnt.model.Assignment",
  13712. "Gnt.column.ResourceName", "Gnt.column.AssignmentUnits",
  13713. "Ext.grid.plugin.CellEditing"],
  13714. extend : "Ext.grid.Panel",
  13715. alias : "widget.assignmentgrid",
  13716. readOnly : false,
  13717. cls : "gnt-assignmentgrid",
  13718. defaultAssignedUnits : 100,
  13719. sorter : {
  13720. sorterFn : function(b, a) {
  13721. var d = b.getUnits(), c = a.getUnits();
  13722. if ((!d && !c) || (d && c)) {
  13723. return b.get("ResourceName") < a.get("ResourceName")
  13724. ? -1
  13725. : 1
  13726. }
  13727. return d ? -1 : 1
  13728. }
  13729. },
  13730. constructor : function(a) {
  13731. this.store = Ext.create("Ext.data.JsonStore", {
  13732. model : Ext.define("Gnt.model.AssignmentEditing", {
  13733. extend : "Gnt.model.Assignment",
  13734. fields : ["ResourceName"]
  13735. })
  13736. });
  13737. this.columns = this.buildColumns();
  13738. if (!this.readOnly) {
  13739. this.plugins = this.buildPlugins()
  13740. }
  13741. Ext.apply(this, {
  13742. selModel : {
  13743. selType : "checkboxmodel",
  13744. mode : "MULTI",
  13745. checkOnly : true,
  13746. selectByPosition : function(b) {
  13747. var c = this.store.getAt(b.row);
  13748. this.select(c, true)
  13749. }
  13750. }
  13751. });
  13752. this.callParent(arguments)
  13753. },
  13754. initComponent : function() {
  13755. this.loadResources();
  13756. this.resourceStore.on({
  13757. datachanged : this.loadResources,
  13758. scope : this
  13759. });
  13760. this.getSelectionModel().on("select", this.onSelect, this, {
  13761. delay : 50
  13762. });
  13763. this.callParent(arguments)
  13764. },
  13765. onSelect : function(b, a) {
  13766. if ((!this.cellEditing || !this.cellEditing.getActiveEditor())
  13767. && !a.getUnits()) {
  13768. a.setUnits(this.defaultAssignedUnits)
  13769. }
  13770. },
  13771. loadResources : function() {
  13772. var d = [], b = this.resourceStore, e;
  13773. for (var c = 0, a = b.getCount(); c < a; c++) {
  13774. e = b.getAt(c).getId();
  13775. d.push({
  13776. ResourceId : e,
  13777. ResourceName : b.getById(e).getName()
  13778. })
  13779. }
  13780. this.store.loadData(d)
  13781. },
  13782. buildPlugins : function() {
  13783. var a = this.cellEditing = Ext.create(
  13784. "Ext.grid.plugin.CellEditing", {
  13785. clicksToEdit : 1
  13786. });
  13787. a.on("edit", this.onEditingDone, this);
  13788. return [a]
  13789. },
  13790. hide : function() {
  13791. this.cellEditing.cancelEdit();
  13792. this.callParent(arguments)
  13793. },
  13794. onEditingDone : function(a, b) {
  13795. if (b.value) {
  13796. this.getSelectionModel().select(b.record, true)
  13797. } else {
  13798. this.getSelectionModel().deselect(b.record);
  13799. b.record.reject()
  13800. }
  13801. },
  13802. buildColumns : function() {
  13803. return [{
  13804. xtype : "resourcenamecolumn",
  13805. resourceStore : this.resourceStore
  13806. }, {
  13807. xtype : "assignmentunitscolumn",
  13808. assignmentStore : this.assignmentStore,
  13809. editor : {
  13810. xtype : "numberfield",
  13811. minValue : 0,
  13812. step : 10
  13813. }
  13814. }]
  13815. },
  13816. loadTaskAssignments : function(d) {
  13817. var b = this.store, f = this.getSelectionModel();
  13818. f.deselectAll(true);
  13819. for (var c = 0, a = b.getCount(); c < a; c++) {
  13820. b.getAt(c).data.Units = "";
  13821. b.getAt(c).data.Id = null
  13822. }
  13823. b.suspendEvents();
  13824. var e = this.assignmentStore.queryBy(function(g) {
  13825. return g.getTaskId() === d
  13826. });
  13827. e.each(function(h) {
  13828. var g = b.findRecord("ResourceId", h
  13829. .getResourceId(), 0, false, true,
  13830. true);
  13831. if (g) {
  13832. g.setUnits(h.getUnits());
  13833. g.set(g.idProperty, h.getId());
  13834. f.select(g, true, true)
  13835. }
  13836. });
  13837. b.resumeEvents();
  13838. b.sort(this.sorter);
  13839. this.getView().refresh()
  13840. }
  13841. });
  13842. Ext.define("Gnt.widget.AssignmentField", {
  13843. extend : "Ext.form.field.Picker",
  13844. alias : "widget.assignmenteditor",
  13845. requires : ["Gnt.widget.AssignmentGrid"],
  13846. matchFieldWidth : false,
  13847. cancelText : "取消",
  13848. closeText : "提交",//2012-09-06 取消按钮
  13849. assignmentStore : null,
  13850. resourceStore : null,
  13851. gridConfig : null,
  13852. createPicker : function() {
  13853. var a = new Gnt.widget.AssignmentGrid(Ext.apply({
  13854. ownerCt : this.ownerCt,
  13855. renderTo : document.body,
  13856. frame : true,
  13857. floating : true,
  13858. hidden : true,
  13859. height : 200,
  13860. width : 300,
  13861. resourceStore : this.resourceStore,
  13862. assignmentStore : this.assignmentStore,
  13863. fbar : this.buildButtons()
  13864. }, this.gridConfig || {}));
  13865. return a
  13866. },
  13867. buildButtons : function() {
  13868. return ["->", {
  13869. text : this.closeText,
  13870. handler : function() {
  13871. var me=this;
  13872. if(this.taskId){
  13873. Ext.Function.defer(this.onGridClose, Ext.isIE
  13874. && !Ext.isIE9 ? 60 : 30, this)
  13875. }else{
  13876. //Ext.Msg.alert('','新建任务不允许分配资源!',me.collapse);
  13877. me.collapse
  13878. showError('新建任务未保存不允许分配资源!');
  13879. }
  13880. },
  13881. scope : this
  13882. }, {
  13883. text : this.cancelText,
  13884. handler : this.collapse,
  13885. scope : this
  13886. }]
  13887. },
  13888. onExpand : function() {
  13889. var a = this.resourceStore, b = this.picker;
  13890. b.loadTaskAssignments(this.taskId)
  13891. },
  13892. onGridClose : function() {
  13893. var b = this.picker.getSelectionModel(), a = b.selected;
  13894. this.fireEvent("select", this, a);
  13895. this.collapse()
  13896. },
  13897. collapseIf : function(b) {
  13898. var a = this;
  13899. if (this.picker && !b.getTarget(".x-editor")
  13900. && !b.getTarget(".x-menu-item")) {
  13901. a.callParent(arguments)
  13902. }
  13903. },
  13904. mimicBlur : function(b) {
  13905. var a = this;
  13906. if (!b.getTarget(".x-editor") && !b.getTarget(".x-menu-item")) {
  13907. a.callParent(arguments)
  13908. }
  13909. }
  13910. });
  13911. Ext.define("Gnt.widget.AssignmentCellEditor", {
  13912. extend : "Ext.grid.CellEditor",
  13913. requires : ["Gnt.model.Assignment", "Gnt.widget.AssignmentField"],
  13914. assignmentStore : null,
  13915. resourceStore : null,
  13916. taskId : null,
  13917. fieldConfig : null,
  13918. allowBlur : false,
  13919. constructor : function(a) {
  13920. a = a || {};
  13921. var b = a.fieldConfig || {};
  13922. this.field = Ext.create("Gnt.widget.AssignmentField", Ext
  13923. .apply(b, {
  13924. assignmentStore : a.assignmentStore,
  13925. resourceStore : a.resourceStore
  13926. }));
  13927. this.field.on({
  13928. select : this.onSelect,
  13929. collapse : this.cancelEdit,
  13930. scope : this
  13931. });
  13932. this.callParent(arguments)
  13933. },
  13934. startEdit : function(c, d, b) {
  13935. this.parentEl = null;
  13936. var a = c.child("div").dom.innerHTML;
  13937. this.taskId = this.field.taskId = b.record.getInternalId();
  13938. this.callParent([c, a === "&nbsp;" ? "" : a]);
  13939. this.field.expand()
  13940. },
  13941. onSelect : function(g, c) {
  13942. this.completeEdit();
  13943. var a = this.assignmentStore, f = this.taskId;
  13944. var e = {};
  13945. var d = [];
  13946. c.each(function(i) {
  13947. var h = i.getUnits();
  13948. if (h > 0) {
  13949. var k = i.getId();
  13950. if (k) {
  13951. e[k] = true;
  13952. a.getById(k).setUnits(h)
  13953. } else {
  13954. var j = Ext.create(a.model);
  13955. j.setTaskId(f);
  13956. j.setResourceId(i.getResourceId());
  13957. j.setUnits(h);
  13958. e[j.internalId] = true;
  13959. d.push(j)
  13960. }
  13961. }
  13962. });
  13963. var b = [];
  13964. a.each(function(h) {
  13965. if (h.getTaskId() === f
  13966. && !e[h.getId() || h.internalId]) {
  13967. b.push(h)
  13968. }
  13969. });
  13970. a.remove(b);
  13971. a.add(d)
  13972. }
  13973. });
  13974. Ext.define("Gnt.widget.DependencyField", {
  13975. extend : "Ext.form.field.Text",
  13976. alias : "widget.dependencyfield",
  13977. requires : ["Gnt.util.DependencyParser"],
  13978. constructor : function(a) {
  13979. var b = this;
  13980. Ext.apply(this, a);
  13981. this.dependencyParser = new Gnt.util.DependencyParser({
  13982. parseNumberFn : function() {
  13983. return Gnt.widget.DurationField.prototype.parseValue
  13984. .apply(b, arguments)
  13985. }
  13986. });
  13987. this.callParent(arguments)
  13988. },
  13989. getDependencies : function() {
  13990. return this.dependencyParser.parse(this.getRawValue())
  13991. },
  13992. getErrors : function(b) {
  13993. if (!b) {
  13994. return
  13995. }
  13996. var a = this.dependencyParser.parse(b);
  13997. if (!a) {
  13998. return ["Invalid dependency format"]
  13999. }
  14000. return this.callParent([a.value])
  14001. }
  14002. });
  14003. Ext.define("Gnt.widget.DependencyEditor", {
  14004. extend : "Ext.grid.CellEditor",
  14005. alias : ["widget.dependencyeditor"],
  14006. context : null,
  14007. taskStore : null,
  14008. dependencyStore : null,
  14009. type : "predecessors",
  14010. constructor : function(a) {
  14011. a = a || {};
  14012. Ext.apply(this, a);
  14013. a.field = a.field || Ext.create("Gnt.widget.DependencyField", {});
  14014. this.callParent([a])
  14015. },
  14016. startEdit : function(b, c, a) {
  14017. this.context = a;
  14018. var d = b.hasCls(".x-grid-cell-inner") ? b : b
  14019. .down(".x-grid-cell-inner");
  14020. c = Ext.String.trim(d.dom.innerText || d.dom.innerHTML).replace(
  14021. "&nbsp;", "");
  14022. return this.callParent([b, c, a])
  14023. },
  14024. completeEdit : function(a) {
  14025. var b = this, e = b.field, d;
  14026. if (!b.editing) {
  14027. return
  14028. }
  14029. d = b.getValue();
  14030. if (!e.isValid()) {
  14031. if (b.revertInvalid !== false) {
  14032. b.cancelEdit(a)
  14033. }
  14034. return
  14035. }
  14036. if (String(d) === String(b.startValue) && b.ignoreNoChange) {
  14037. b.hideEdit(a);
  14038. return
  14039. }
  14040. if (b.fireEvent("beforecomplete", b, d, b.startValue) !== false) {
  14041. d = b.getValue();
  14042. if (b.updateEl && b.boundEl) {
  14043. b.boundEl.update(d)
  14044. }
  14045. var c = this.field.getDependencies();
  14046. if (this.validateDependencies(c)) {
  14047. this.processDependencies(c);
  14048. b.hideEdit(a);
  14049. b.fireEvent("complete", b, d, b.startValue)
  14050. }
  14051. }
  14052. },
  14053. validateDependencies : function(e) {
  14054. var a = this.type === "predecessors";
  14055. for (var d = 0; d < e.length; d++) {
  14056. var c = a ? e[d].taskId : this.context.record.getInternalId();
  14057. var b = !a ? e[d].taskId : this.context.record.getInternalId();
  14058. if (!this.taskStore.getById(e[d].taskId)
  14059. || (!this.dependencyStore.areTasksLinked(c, b) && !this.dependencyStore
  14060. .isValidDependency(c, b))) {
  14061. return false
  14062. }
  14063. }
  14064. return true
  14065. },
  14066. processDependencies : function(h) {
  14067. var m = this.dependencyStore, d = this.context, e = d.record, a = Ext.Array
  14068. .pluck(h, "taskId"), k = this.type === "predecessors", l = k
  14069. ? e.getIncomingDependencies()
  14070. : e.getOutgoingDependencies(), c = [];
  14071. for (var g = 0; g < l.length; g++) {
  14072. if (!Ext.Array.contains(a,
  14073. l[g][k ? "getSourceId" : "getTargetId"]())) {
  14074. c.push(l[g])
  14075. }
  14076. }
  14077. if (c.length > 0) {
  14078. m.remove(c)
  14079. }
  14080. var n = [];
  14081. for (g = 0; g < h.length; g++) {
  14082. var f = h[g];
  14083. var b = f.taskId;
  14084. var j = m.getByTaskIds(b, e.getInternalId());
  14085. if (j) {
  14086. j.beginEdit();
  14087. j.setType(f.type);
  14088. j.setLag(f.lag);
  14089. j.setLagUnit(f.lagUnit);
  14090. j.endEdit()
  14091. } else {
  14092. n.push(new m.model({
  14093. fromTask : k ? b : e.getInternalId(),
  14094. toTask : k ? e.getInternalId() : b,
  14095. type : f.type,
  14096. lag : f.lag,
  14097. lagUnit : f.lagUnit
  14098. }))
  14099. }
  14100. }
  14101. if (n.length > 0) {
  14102. m.add(n)
  14103. }
  14104. if (n.length || c.length) {
  14105. e.afterEdit(["--dependency--"])
  14106. }
  14107. }
  14108. });
  14109. Ext.define("Gnt.widget.DurationField", {
  14110. extend : "Ext.form.field.Number",
  14111. requires : ["Gnt.util.DurationParser"],
  14112. alias : "widget.durationfield",
  14113. alternateClassName : "Gnt.column.duration.Field",
  14114. disableKeyFilter : true,
  14115. minValue : 0,
  14116. durationUnit : "h",
  14117. invalidText : "Invalid duration value",
  14118. useAbbreviation : false,
  14119. durationParser : null,
  14120. durationParserConfig : null,
  14121. constructor : function(a) {
  14122. var b = this;
  14123. Ext.apply(this, a);
  14124. this.durationParser = new Gnt.util.DurationParser(Ext.apply({
  14125. parseNumberFn : function() {
  14126. return b.parseValue.apply(b, arguments)
  14127. },
  14128. allowDecimals : this.decimalPrecision > 0
  14129. }, this.durationParserConfig));
  14130. this.callParent(arguments)
  14131. },
  14132. rawToValue : function(b) {
  14133. var a = this.parseDuration(b);
  14134. if (!a) {
  14135. return null
  14136. }
  14137. this.durationUnit = a.unit;
  14138. return a.value != null ? a.value : null
  14139. },
  14140. valueToRaw : function(a) {
  14141. if (Ext.isNumber(a)) {
  14142. return parseFloat(Ext.Number.toFixed(a,
  14143. this.decimalPrecision))
  14144. + " "
  14145. + Sch.util.Date[this.useAbbreviation
  14146. ? "getShortNameOfUnit"
  14147. : "getReadableNameOfUnit"](
  14148. this.durationUnit, a !== 1)
  14149. }
  14150. return ""
  14151. },
  14152. parseDuration : function(b) {
  14153. if (b == null) {
  14154. return null
  14155. }
  14156. var a = this;
  14157. var c = this.durationParser.parse(b);
  14158. if (!c) {
  14159. return null
  14160. }
  14161. c.unit = c.unit || this.durationUnit;
  14162. return c
  14163. },
  14164. getDurationValue : function() {
  14165. var a = this;
  14166. return this.parseDuration(this.getRawValue())
  14167. },
  14168. getErrors : function(b) {
  14169. var a = this.parseDuration(b);
  14170. if (!a) {
  14171. return [this.invalidText]
  14172. }
  14173. return this.callParent([a.value])
  14174. },
  14175. checkChange : function() {
  14176. if (!this.suspendCheckChange) {
  14177. var d = this, c = d.getDurationValue(), a = d.lastValue;
  14178. var b = c && !a || !c && a || c && a
  14179. && (c.value != a.value || c.unit != a.unit);
  14180. if (b && !d.isDestroyed) {
  14181. d.lastValue = c;
  14182. d.fireEvent("change", d, c, a);
  14183. d.onChange(c, a)
  14184. }
  14185. }
  14186. }
  14187. });
  14188. Ext.define("Gnt.widget.DurationEditor", {
  14189. extend : "Ext.grid.CellEditor",
  14190. alias : ["widget.durationeditor", "widget.durationcolumneditor"],
  14191. alternateClassName : "Gnt.column.duration.Editor",
  14192. context : null,
  14193. decimalPrecision : 2,
  14194. getDurationUnitMethod : "getDurationUnit",
  14195. setDurationMethod : "setDuration",
  14196. useAbbreviation : false,
  14197. constructor : function(a) {
  14198. a = a || {};
  14199. Ext.apply(this, a);
  14200. a.field = a.field || Ext.create("Gnt.widget.DurationField", {
  14201. useAbbreviation : this.useAbbreviation,
  14202. decimalPrecision : this.decimalPrecision
  14203. });
  14204. this.callParent([a])
  14205. },
  14206. startEdit : function(c, b, a) {
  14207. this.context = a;
  14208. this.field.durationUnit = a.record[this.getDurationUnitMethod]();
  14209. return this.callParent(arguments)
  14210. },
  14211. completeEdit : function(a) {
  14212. var d = this, g = d.field, e;
  14213. if (!d.editing) {
  14214. return
  14215. }
  14216. if (g.assertValue) {
  14217. g.assertValue()
  14218. }
  14219. e = d.getValue();
  14220. if (!g.isValid()) {
  14221. if (d.revertInvalid !== false) {
  14222. d.cancelEdit(a)
  14223. }
  14224. return
  14225. }
  14226. if (String(e) === String(d.startValue) && d.ignoreNoChange) {
  14227. d.hideEdit(a);
  14228. return
  14229. }
  14230. if (d.fireEvent("beforecomplete", d, e, d.startValue) !== false) {
  14231. e = d.getValue();
  14232. if (d.updateEl && d.boundEl) {
  14233. d.boundEl.update(e)
  14234. }
  14235. d.hideEdit(a);
  14236. var c = this.context;
  14237. var b = c.record;
  14238. var f = this.field.getDurationValue();
  14239. b[this.setDurationMethod](f.value, f.unit);
  14240. d.fireEvent("complete", d, e, d.startValue)
  14241. }
  14242. }
  14243. });
  14244. Ext.define("Gnt.column.Dependency", {
  14245. extend : "Ext.grid.column.Column",
  14246. requires : ["Gnt.widget.DependencyField", "Gnt.widget.DependencyEditor"],
  14247. separator : ";",
  14248. type : "predecessors",
  14249. dataIndex : "--dependency--",
  14250. constructor : function(a) {
  14251. a = a || {};
  14252. Ext.apply(this, a);
  14253. a.editor = a.editor || Ext.create("Gnt.widget.DependencyEditor", {
  14254. type : this.type
  14255. });
  14256. if (!a.editor.isFormField) {
  14257. a.editor = Ext.ComponentManager
  14258. .create(a.editor, "dependencyeditor")
  14259. }
  14260. this.scope = this;
  14261. this.callParent([a])
  14262. },
  14263. beforeRender : function() {
  14264. var a = this.up("ganttpanel");
  14265. a.registerLockedDependencyListeners();
  14266. this.dependencyStore = a.getDependencyStore();
  14267. if (this.editor) {
  14268. this.editor.taskStore = a.getTaskStore();
  14269. this.editor.dependencyStore = a.getDependencyStore()
  14270. }
  14271. this.callParent(arguments)
  14272. },
  14273. renderer : function(j, n, a) {
  14274. if (!a.isEditable(this.dataIndex)) {
  14275. n.tdCls = (n.tdCls || "") + " sch-column-readonly"
  14276. }
  14277. var h = this.type === "predecessors", m = this.getDependencies(a), k = Gnt.util.DependencyParser.prototype.types, e = Gnt.model.Dependency.Type.EndToStart, l = [];
  14278. for (var d = 0; d < m.length; d++) {
  14279. var g = m[d];
  14280. if (g.isValid(false)) {
  14281. var f = g.getType(), b = g.getLag(), c = g.getLagUnit();
  14282. l.push(Ext.String.format("{0}{1}{2}{3}{4}", h
  14283. ? g.getSourceId()
  14284. : g.getTargetId(), b || f !== e ? k[f] : "", b
  14285. ? "+"
  14286. : "", b || "", b && c !== "d" ? c : ""))
  14287. }
  14288. }
  14289. return l.join(this.separator)
  14290. }
  14291. });
  14292. Ext.define("Gnt.column.Successor", {
  14293. extend : "Gnt.column.Dependency",
  14294. alias : "widget.successorcolumn",
  14295. text : "Successors",
  14296. type : "successors",
  14297. getDependencies : function(a) {
  14298. return a.getOutgoingDependencies()
  14299. }
  14300. });
  14301. Ext.define("Gnt.column.Predecessor", {
  14302. extend : "Gnt.column.Dependency",
  14303. alias : "widget.predecessorcolumn",
  14304. text : "Predecessors",
  14305. type : "predecessors",
  14306. getDependencies : function(a) {
  14307. return a.getIncomingDependencies()
  14308. }
  14309. });
  14310. Ext.define("Gnt.column.Duration", {
  14311. extend : "Ext.grid.column.Column",
  14312. alias : "widget.durationcolumn",
  14313. requires : ["Gnt.widget.DurationField", "Gnt.widget.DurationEditor"],
  14314. text : "Duration",
  14315. width : 80,
  14316. align : "left",
  14317. decimalPrecision : 2,
  14318. getDurationUnitMethod : "getDurationUnit",
  14319. setDurationMethod : "setDuration",
  14320. useAbbreviation : false,
  14321. constructor : function(a) {
  14322. a = a || {};
  14323. Ext.apply(this, a);
  14324. a.editor = a.editor
  14325. || Ext.create("Gnt.widget.DurationEditor", {
  14326. useAbbreviation : this.useAbbreviation,
  14327. decimalPrecision : this.decimalPrecision,
  14328. getDurationUnitMethod : this.getDurationUnitMethod,
  14329. setDurationMethod : this.setDurationMethod
  14330. });
  14331. if (!a.editor.isFormField) {
  14332. a.editor = Ext.ComponentManager.create(a.editor,
  14333. "durationcolumneditor")
  14334. }
  14335. this.scope = this;
  14336. this.callParent([a]);
  14337. this.mon(this.editor, "beforestartedit",
  14338. this.onBeforeStartEdit, this)
  14339. },
  14340. beforeRender : function() {
  14341. if (!this.dataIndex) {
  14342. var a = this.up("treepanel");
  14343. this.dataIndex = a.store.model.prototype.durationField
  14344. }
  14345. this.callParent(arguments)
  14346. },
  14347. onBeforeStartEdit : function(b) {
  14348. var a = b.context.record;
  14349. return a.isEditable(this.dataIndex)
  14350. },
  14351. renderer : function(b, c, a) {
  14352. if (!Ext.isNumber(b)) {
  14353. return ""
  14354. }
  14355. if (!a.isEditable(this.dataIndex)) {
  14356. c.tdCls = (c.tdCls || "") + " sch-column-readonly"
  14357. }
  14358. b = parseFloat(Ext.Number.toFixed(b, this.decimalPrecision));
  14359. return b
  14360. + " "
  14361. + Sch.util.Date[this.useAbbreviation
  14362. ? "getShortNameOfUnit"
  14363. : "getReadableNameOfUnit"](
  14364. a[this.getDurationUnitMethod](), b !== 1)
  14365. }
  14366. });
  14367. Ext.define("Gnt.column.Effort", {
  14368. extend : "Gnt.column.Duration",
  14369. alias : "widget.effortcolumn",
  14370. text : "Effort",
  14371. getDurationUnitMethod : "getEffortUnit",
  14372. setDurationMethod : "setEffort",
  14373. beforeRender : function() {
  14374. if (!this.dataIndex) {
  14375. var a = this.up("treepanel");
  14376. this.dataIndex = a.store.model.prototype.effortField
  14377. }
  14378. this.callParent(arguments)
  14379. }
  14380. });
  14381. Ext.define("Gnt.widget.Calendar", {
  14382. extend : "Ext.picker.Date",
  14383. alias : "widget.ganttcalendar",
  14384. requires : ["Gnt.data.Calendar", "Sch.util.Date"],
  14385. calendar : null,
  14386. startDate : null,
  14387. endDate : null,
  14388. disabledDatesText : "Holiday",
  14389. initComponent : function() {
  14390. if (!this.calendar) {
  14391. Ext.Error
  14392. .raise('Required attribute "calendar" missing during initialization of `Gnt.widget.Calendar`')
  14393. }
  14394. if (!this.startDate) {
  14395. Ext.Error
  14396. .raise('Required attribute "startDate" missing during initialization of `Gnt.widget.Calendar`')
  14397. }
  14398. if (!this.endDate) {
  14399. this.endDate = Sch.util.Date.add(this.startDate,
  14400. Sch.util.Date.MONTH, 1)
  14401. }
  14402. this.setCalendar(this.calendar);
  14403. this.minDate = this.value = this.startDate;
  14404. this.injectDates();
  14405. this.callParent(arguments)
  14406. },
  14407. injectDates : function() {
  14408. var a = this;
  14409. var b = a.disabledDates = [];
  14410. Ext.each(a.calendar.getHolidaysRanges(a.startDate, a.endDate),
  14411. function(c) {
  14412. c.forEachDate(function(d) {
  14413. b.push(Ext.Date.format(d, a.format))
  14414. })
  14415. });
  14416. a.setDisabledDates(b)
  14417. },
  14418. setCalendar : function(b) {
  14419. var a = {
  14420. update : this.injectDates,
  14421. remove : this.injectDates,
  14422. add : this.injectDates,
  14423. load : this.injectDates,
  14424. clear : this.injectDates,
  14425. scope : this
  14426. };
  14427. if (this.calendar) {
  14428. this.calendar.un(a)
  14429. }
  14430. this.calendar = b;
  14431. b.on(a)
  14432. }
  14433. });
  14434. Ext.define("Gnt.widget.calendar.DayGrid", {
  14435. extend : "Ext.grid.Panel",
  14436. title : "Day overrides",
  14437. height : 180,
  14438. nameText : "Name",
  14439. dateText : "Date",
  14440. noNameText : "[Day override]",
  14441. initComponent : function() {
  14442. Ext.applyIf(this, {
  14443. store : Ext.create("Gnt.data.Calendar", {
  14444. proxy : "memory"
  14445. }),
  14446. plugins : [Ext.create(
  14447. "Ext.grid.plugin.CellEditing", {
  14448. clicksToEdit : 2
  14449. })],
  14450. columns : [{
  14451. header : this.nameText,
  14452. dataIndex : "Name",
  14453. flex : 1,
  14454. editor : {
  14455. allowBlank : false
  14456. }
  14457. }, {
  14458. header : this.dateText,
  14459. dataIndex : "Date",
  14460. width : 100,
  14461. xtype : "datecolumn",
  14462. editor : {
  14463. xtype : "datefield"
  14464. }
  14465. }]
  14466. });
  14467. this.callParent(arguments)
  14468. }
  14469. });
  14470. Ext.define("Gnt.widget.calendar.WeekGrid", {
  14471. extend : "Ext.grid.Panel",
  14472. requires : ["Gnt.model.WeekAvailability"],
  14473. title : "Week overrides",
  14474. border : true,
  14475. height : 220,
  14476. nameText : "Name",
  14477. startDateText : "Start date",
  14478. endDateText : "End date",
  14479. initComponent : function() {
  14480. Ext.applyIf(this, {
  14481. store : Ext.create("Ext.data.Store", {
  14482. model : "Gnt.model.WeekAvailability",
  14483. proxy : "memory"
  14484. })
  14485. });
  14486. Ext.applyIf(this, {
  14487. columns : [{
  14488. header : this.nameText,
  14489. dataIndex : this.store.model.prototype.nameField,
  14490. flex : 1,
  14491. editor : {
  14492. allowBlank : false
  14493. }
  14494. }, {
  14495. header : this.startDateText,
  14496. dataIndex : this.store.model.prototype.startDateField,
  14497. width : 100,
  14498. xtype : "datecolumn",
  14499. editor : {
  14500. xtype : "datefield"
  14501. }
  14502. }, {
  14503. header : this.endDateText,
  14504. dataIndex : this.store.model.prototype.endDateField,
  14505. width : 100,
  14506. xtype : "datecolumn",
  14507. editor : {
  14508. xtype : "datefield"
  14509. }
  14510. }],
  14511. plugins : [Ext.create("Ext.grid.plugin.CellEditing", {
  14512. clicksToEdit : 2
  14513. })]
  14514. });
  14515. this.callParent(arguments)
  14516. }
  14517. });
  14518. Ext.define("Gnt.widget.calendar.ResourceCalendarGrid", {
  14519. extend : "Ext.grid.Panel",
  14520. requires : ["Gnt.data.Calendar", "Sch.util.Date"],
  14521. alias : "widget.resourcecalendargrid",
  14522. resourceStore : null,
  14523. calendarStore : null,
  14524. initComponent : function() {
  14525. var a = this;
  14526. this.calendarStore = this.calendarStore
  14527. || Ext.create("Ext.data.Store", {
  14528. fields : ["Id", "Name"]
  14529. });
  14530. Ext.apply(a, {
  14531. store : a.resourceStore,
  14532. columns : [{
  14533. header : "Name",
  14534. dataIndex : "Name",
  14535. flex : 1
  14536. }, {
  14537. header : "Calendar",
  14538. dataIndex : "CalendarId",
  14539. flex : 1,
  14540. renderer : function(f, h, b, e, d, c) {
  14541. if (!f) {
  14542. var g = b.getCalendar();
  14543. f = g ? g.calendarId : ""
  14544. }
  14545. var i = a.calendarStore.getById(f);
  14546. return i ? i.get("Name") : f
  14547. },
  14548. editor : {
  14549. xtype : "combobox",
  14550. store : a.calendarStore,
  14551. queryMode : "local",
  14552. displayField : "Name",
  14553. valueField : "Id",
  14554. editable : false,
  14555. allowBlank : false
  14556. }
  14557. }],
  14558. border : true,
  14559. height : 180,
  14560. plugins : [Ext.create(
  14561. "Ext.grid.plugin.CellEditing", {
  14562. clicksToEdit : 2
  14563. })]
  14564. });
  14565. this.calendarStore.loadData(this.getCalendarData());
  14566. this.callParent(arguments)
  14567. },
  14568. getCalendarData : function() {
  14569. var a = [];
  14570. Ext.Array.each(Gnt.data.Calendar.getAllCalendars(),
  14571. function(b) {
  14572. a.push({
  14573. Id : b.calendarId,
  14574. Name : b.name || b.calendarId
  14575. })
  14576. });
  14577. return a
  14578. }
  14579. });
  14580. Ext.define("Gnt.widget.calendar.DayAvailabilityGrid", {
  14581. extend : "Ext.grid.Panel",
  14582. requires : ["Gnt.data.Calendar", "Sch.util.Date"],
  14583. alias : "widget.dayavailabilitygrid",
  14584. height : 160,
  14585. calendarDay : null,
  14586. startText : "Start",
  14587. endText : "End",
  14588. addText : "Add",
  14589. removeText : "Remove",
  14590. workingTimeText : "Working time",
  14591. nonworkingTimeText : "Non-working time",
  14592. getDayTypeRadioGroup : function() {
  14593. return this.down('radiogroup[name="dayType"]')
  14594. },
  14595. initComponent : function() {
  14596. Ext.applyIf(this, {
  14597. store : Ext.create("Ext.data.Store", {
  14598. fields : ["startTime", "endTime"],
  14599. proxy : {
  14600. type : "memory",
  14601. reader : {
  14602. type : "json"
  14603. }
  14604. }
  14605. }),
  14606. plugins : [Ext.create("Ext.grid.plugin.CellEditing", {
  14607. clicksToEdit : 2
  14608. })],
  14609. dockedItems : [{
  14610. xtype : "radiogroup",
  14611. dock : "top",
  14612. name : "dayType",
  14613. padding : "0 5px",
  14614. margin : 0,
  14615. items : [{
  14616. boxLabel : this.workingTimeText,
  14617. name : "IsWorkingDay",
  14618. inputValue : true
  14619. }, {
  14620. boxLabel : this.nonworkingTimeText,
  14621. name : "IsWorkingDay",
  14622. inputValue : false
  14623. }],
  14624. listeners : {
  14625. change : this.onDayTypeChanged,
  14626. scope : this
  14627. }
  14628. }],
  14629. tbar : this.buildToolbar(),
  14630. columns : [{
  14631. header : this.startText,
  14632. xtype : "datecolumn",
  14633. format : "g:i a",
  14634. dataIndex : "startTime",
  14635. flex : 1,
  14636. editor : {
  14637. xtype : "timefield",
  14638. allowBlank : false,
  14639. initDate : "31/12/1899"
  14640. }
  14641. }, {
  14642. header : this.endText,
  14643. xtype : "datecolumn",
  14644. format : "g:i a",
  14645. dataIndex : "endTime",
  14646. flex : 1,
  14647. editor : {
  14648. allowBlank : false,
  14649. xtype : "timefield",
  14650. initDate : "31/12/1899"
  14651. }
  14652. }],
  14653. listeners : {
  14654. selectionchange : this.onAvailabilityGridSelectionChange,
  14655. scope : this
  14656. }
  14657. });
  14658. this.callParent(arguments)
  14659. },
  14660. buildToolbar : function() {
  14661. this.addButton = new Ext.Button({
  14662. text : this.addText,
  14663. iconCls : "gnt-action-add",
  14664. handler : this.addAvailability,
  14665. scope : this
  14666. });
  14667. this.removeButton = new Ext.Button({
  14668. text : this.removeText,
  14669. iconCls : "gnt-action-remove",
  14670. handler : this.removeAvailability,
  14671. scope : this,
  14672. disabled : true
  14673. });
  14674. return [this.addButton, this.removeButton]
  14675. },
  14676. onAvailabilityGridSelectionChange : function(a) {
  14677. if (this.removeButton) {
  14678. this.removeButton.setDisabled(!a || a.getSelection().length === 0)
  14679. }
  14680. },
  14681. onDayTypeChanged : function(a) {
  14682. var b = a.getValue();
  14683. if (Ext.isArray(b.IsWorkingDay)) {
  14684. return
  14685. }
  14686. this.getView().setDisabled(!b.IsWorkingDay)
  14687. },
  14688. addAvailability : function() {
  14689. var a = this.getStore(), b = a.count();
  14690. if (b >= 5) {
  14691. return
  14692. }
  14693. a.add({
  14694. startTime : new Date(0, 0, 0, 12, 0),
  14695. endTime : new Date(0, 0, 0, 13, 0)
  14696. });
  14697. if (b + 1 >= 5 && this.addButton) {
  14698. this.addButton.setDisabled(true)
  14699. }
  14700. },
  14701. removeAvailability : function() {
  14702. var b = this.getStore(), c = b.count(), d = this.getSelectionModel();
  14703. if (!d || d.getSelection().length === 0) {
  14704. return
  14705. }
  14706. var a = d.getSelection()[0];
  14707. b.remove(a);
  14708. if (c < 5 && this.addButton) {
  14709. this.addButton.setDisabled(false)
  14710. }
  14711. },
  14712. editAvailability : function(a) {
  14713. this.calendarDay = a;
  14714. this.getDayTypeRadioGroup().setValue({
  14715. IsWorkingDay : a.getIsWorkingDay()
  14716. });
  14717. var b = this.calendarDay.getAvailability();
  14718. this.getStore().loadData(b)
  14719. },
  14720. isWorkingDay : function() {
  14721. return this.getDayTypeRadioGroup().getValue().IsWorkingDay
  14722. },
  14723. isValid : function() {
  14724. var c = this.getDayTypeRadioGroup().getValue().IsWorkingDay, b = [];
  14725. if (c) {
  14726. try {
  14727. b = this.getIntervals();
  14728. this.calendarDay.verifyAvailability(b)
  14729. } catch (a) {
  14730. Ext.MessageBox.alert("Error", a);
  14731. return false
  14732. }
  14733. }
  14734. return true
  14735. },
  14736. getIntervals : function() {
  14737. var a = [];
  14738. this.getStore().each(function(b) {
  14739. a.push({
  14740. startTime : b.get("startTime"),
  14741. endTime : b.get("endTime")
  14742. })
  14743. });
  14744. return a
  14745. }
  14746. });
  14747. Ext.define("Gnt.widget.calendar.WeekEditor", {
  14748. extend : "Ext.form.Panel",
  14749. requires : ["Ext.grid.*", "Gnt.data.Calendar", "Sch.util.Date"],
  14750. alias : "widget.calendarweekeditor",
  14751. layout : "anchor",
  14752. defaults : {
  14753. border : false,
  14754. anchor : "100%"
  14755. },
  14756. getDefaultWeekAvailabilityHandler : null,
  14757. startDate : null,
  14758. endDate : null,
  14759. startHeaderText : "Start",
  14760. endHeaderText : "End",
  14761. defaultTimeText : "Default time",
  14762. workingTimeText : "Working time",
  14763. nonworkingTimeText : "Non-working time",
  14764. addText : "Add",
  14765. removeText : "Remove",
  14766. weekAvailability : null,
  14767. currentWeekDay : null,
  14768. _weekDaysGrid : null,
  14769. getWeekDaysGrid : function() {
  14770. if (this._weekDaysGrid != null) {
  14771. return this._weekDaysGrid
  14772. }
  14773. var a = Ext.Date.dayNames;
  14774. return this._weekDaysGrid = Ext.create("Ext.grid.Panel", {
  14775. hideHeaders : true,
  14776. height : 160,
  14777. columns : [{
  14778. header : "",
  14779. dataIndex : "name",
  14780. flex : 1
  14781. }],
  14782. store : Ext.create("Ext.data.JsonStore", {
  14783. fields : ["id", "name"],
  14784. idProperty : "id",
  14785. data : [{
  14786. id : 1,
  14787. name : a[1]
  14788. }, {
  14789. id : 2,
  14790. name : a[2]
  14791. }, {
  14792. id : 3,
  14793. name : a[3]
  14794. }, {
  14795. id : 4,
  14796. name : a[4]
  14797. }, {
  14798. id : 5,
  14799. name : a[5]
  14800. }, {
  14801. id : 6,
  14802. name : a[6]
  14803. }, {
  14804. id : 0,
  14805. name : a[0]
  14806. }]
  14807. }),
  14808. listeners : {
  14809. selectionchange : {
  14810. fn : this.onWeekDaysListSelectionChange,
  14811. scope : this
  14812. }
  14813. }
  14814. })
  14815. },
  14816. _availabilityGrid : null,
  14817. getAvailabilityGrid : function() {
  14818. if (!this._availabilityGrid) {
  14819. this._availabilityGrid = Ext.create("Ext.grid.Panel", {
  14820. height : 160,
  14821. plugins : [Ext.create("Ext.grid.plugin.CellEditing", {
  14822. clicksToEdit : 2
  14823. })],
  14824. tbar : [{
  14825. text : this.addText,
  14826. action : "add",
  14827. handler : this.addAvailability,
  14828. scope : this,
  14829. iconCls : "gnt-action-add"
  14830. }, {
  14831. text : this.removeText,
  14832. iconCls : "gnt-action-remove",
  14833. action : "remove",
  14834. handler : this.removeAvailability,
  14835. scope : this
  14836. }],
  14837. store : Ext.create("Ext.data.Store", {
  14838. fields : ["startTime", "endTime"],
  14839. proxy : {
  14840. type : "memory",
  14841. reader : {
  14842. type : "json"
  14843. }
  14844. }
  14845. }),
  14846. columns : [{
  14847. header : this.startHeaderText,
  14848. xtype : "datecolumn",
  14849. format : "g:i a",
  14850. dataIndex : "startTime",
  14851. flex : 1,
  14852. editor : {
  14853. xtype : "timefield",
  14854. allowBlank : false,
  14855. initDate : "31/12/1899"
  14856. }
  14857. }, {
  14858. header : this.endHeaderText,
  14859. xtype : "datecolumn",
  14860. format : "g:i a",
  14861. dataIndex : "endTime",
  14862. flex : 1,
  14863. editor : {
  14864. allowBlank : false,
  14865. xtype : "timefield",
  14866. initDate : "31/12/1899"
  14867. }
  14868. }],
  14869. listeners : {
  14870. selectionchange : this.onAvailabilityGridSelectionChange,
  14871. scope : this
  14872. }
  14873. })
  14874. }
  14875. return this._availabilityGrid
  14876. },
  14877. getDayTypeRadioGroup : function() {
  14878. return this.down('radiogroup[name="dayType"]')
  14879. },
  14880. initComponent : function() {
  14881. if (!this.getDefaultWeekAvailabilityHandler
  14882. && !Ext.isFunction(this.getDefaultWeekAvailabilityHandler)) {
  14883. Ext.Error
  14884. .raise('Required attribute "getDefaultWeekAvailabilityHandler" is missed during initialization of `Gnt.widget.calendar.WeekEditor`')
  14885. }
  14886. this.items = [{
  14887. xtype : "radiogroup",
  14888. padding : "0 5px",
  14889. name : "dayType",
  14890. items : [{
  14891. boxLabel : this.defaultTimeText,
  14892. name : "IsWorkingDay",
  14893. inputValue : 0
  14894. }, {
  14895. boxLabel : this.workingTimeText,
  14896. name : "IsWorkingDay",
  14897. inputValue : 1
  14898. }, {
  14899. boxLabel : this.nonworkingTimeText,
  14900. name : "IsWorkingDay",
  14901. inputValue : 2
  14902. }],
  14903. listeners : {
  14904. change : {
  14905. fn : this.onDayTypeChanged,
  14906. scope : this
  14907. }
  14908. }
  14909. }, {
  14910. layout : "column",
  14911. padding : "0 0 5px 0",
  14912. defaults : {
  14913. border : false
  14914. },
  14915. items : [{
  14916. margin : "0 10px 0 5px",
  14917. columnWidth : 0.5,
  14918. items : this.getWeekDaysGrid()
  14919. }, {
  14920. columnWidth : 0.5,
  14921. margin : "0 5px 0 0",
  14922. items : this.getAvailabilityGrid()
  14923. }]
  14924. }];
  14925. this.callParent(arguments)
  14926. },
  14927. addAvailability : function() {
  14928. var b = this.getAvailabilityGrid(), a = b.getStore(), c = a.count();
  14929. if (c >= 5) {
  14930. return
  14931. }
  14932. a.add({
  14933. startTime : new Date(0, 0, 0, 12, 0),
  14934. endTime : new Date(0, 0, 0, 13, 0)
  14935. });
  14936. if (c + 1 >= 5) {
  14937. b.down('button[action="add"]').setDisabled(true)
  14938. }
  14939. },
  14940. removeAvailability : function() {
  14941. var c = this.getAvailabilityGrid(), b = c.getStore(), d = b.count(), e = c
  14942. .getSelectionModel();
  14943. if (!e || e.getSelection().length === 0) {
  14944. return
  14945. }
  14946. var a = e.getSelection()[0];
  14947. b.remove(a);
  14948. if (d < 5) {
  14949. c.down('button[action="add"]').setDisabled(false)
  14950. }
  14951. },
  14952. editAvailability : function(b, e, a) {
  14953. this.startDate = b;
  14954. this.endDate = e;
  14955. this.weekAvailability = a;
  14956. var c = this.getWeekDaysGrid(), d = c.getStore().getAt(0);
  14957. c.getSelectionModel().select(d, false, true);
  14958. this.refreshView(d)
  14959. },
  14960. applyChanges : function(a) {
  14961. if (!this.validateAndSave()) {
  14962. return false
  14963. }
  14964. if (a && Ext.isFunction(a)) {
  14965. a.call(this, this.weekAvailability)
  14966. }
  14967. },
  14968. getIntervals : function() {
  14969. var a = [];
  14970. this.getAvailabilityGrid().getStore().each(function(b) {
  14971. a.push({
  14972. startTime : b.get("startTime"),
  14973. endTime : b.get("endTime")
  14974. })
  14975. });
  14976. return a
  14977. },
  14978. onWeekDaysListSelectionChange : function(a, b) {
  14979. if (!this.validateAndSave()) {
  14980. return false
  14981. }
  14982. this.refreshView(b[0])
  14983. },
  14984. validateAndSave : function() {
  14985. var c = this.currentWeekDay.get("IsWorkingDay"), b = [];
  14986. if (c) {
  14987. try {
  14988. b = this.getIntervals();
  14989. this.currentWeekDay.verifyAvailability(b)
  14990. } catch (a) {
  14991. Ext.MessageBox.alert("Error", a);
  14992. return false
  14993. }
  14994. }
  14995. this.currentWeekDay.setAvailability(b);
  14996. return true
  14997. },
  14998. refreshView : function(d) {
  14999. var g = d.getId(), b = this.weekAvailability[g], f = this
  15000. .getDayTypeRadioGroup(), e = b.getAvailability(), c = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
  15001. .exec(b.getId()), a = !c ? 0 : (b.get("IsWorkingDay") ? 1 : 2);
  15002. this.currentWeekDay = b;
  15003. f.setValue({
  15004. IsWorkingDay : [a]
  15005. });
  15006. this.getAvailabilityGrid().getStore().loadData(e)
  15007. },
  15008. onAvailabilityGridSelectionChange : function(b) {
  15009. var a = this.getAvailabilityGrid();
  15010. a.down('button[action="remove"]').setDisabled(!b
  15011. || b.getSelection().length === 0)
  15012. },
  15013. onDayTypeChanged : function(g) {
  15014. var c = g.getValue();
  15015. if (Ext.isArray(c.IsWorkingDay)) {
  15016. return
  15017. }
  15018. var a = this.getWeekDaysGrid(), d = a.getSelectionModel(), b = d
  15019. .getSelection()[0].getId(), e = this.weekAvailability[b]
  15020. .get("Name"), f = [], i = Ext.Date.format(this.startDate,
  15021. "Y/m/d"), j = Ext.Date.format(this.endDate, "Y/m/d");
  15022. switch (c.IsWorkingDay) {
  15023. case 0 :
  15024. var h = this.getDefaultWeekAvailabilityHandler()[b];
  15025. h.set("Name", e);
  15026. h.set("Date", null);
  15027. f = h.getAvailability();
  15028. this.weekAvailability[b] = h;
  15029. break;
  15030. default :
  15031. f = this.weekAvailability[b].getAvailability();
  15032. this.currentWeekDay.set("Id", Ext.String.format("{0}-{1}-{2}",
  15033. b, i, j));
  15034. this.currentWeekDay.set("IsWorkingDay", c.IsWorkingDay === 1);
  15035. break
  15036. }
  15037. this.getAvailabilityGrid().getStore().loadData(Ext.clone(f));
  15038. this.getAvailabilityGrid().setDisabled(c.IsWorkingDay !== 1)
  15039. }
  15040. });
  15041. Ext.define("Gnt.widget.calendar.DatePicker", {
  15042. extend : "Ext.picker.Date",
  15043. alias : "widget.gntdatepicker",
  15044. calendar : null,
  15045. workingDayCls : "gnt-datepicker-workingday",
  15046. nonWorkingDayCls : "gnt-datepicker-nonworkingday",
  15047. overriddenDayCls : "gnt-datepicker-overriddenday",
  15048. overriddenWeekDayCls : "gnt-datepicker-overriddenweekday",
  15049. _weeks : null,
  15050. getWeekOverrides : function() {
  15051. return this._weeks
  15052. },
  15053. setWeekOverrides : function(a) {
  15054. this._weeks = a
  15055. },
  15056. _days : null,
  15057. getDayOverrides : function() {
  15058. return this._days
  15059. },
  15060. setDayOverrides : function(a) {
  15061. this._days = a
  15062. },
  15063. update : function(b, e) {
  15064. var d = this, c = 0, a = d.cells.elements;
  15065. this.removeCustomCls();
  15066. this.callParent(arguments);
  15067. for (; c < d.numDays; ++c) {
  15068. b = a[c].firstChild.dateValue;
  15069. a[c].className += " " + this.getDateCls(b)
  15070. }
  15071. },
  15072. getDateCls : function(d) {
  15073. var b = "", f = 0, g = this;
  15074. d = new Date(d);
  15075. if (d.getMonth() !== this.getActive().getMonth()) {
  15076. return
  15077. }
  15078. if (this.getDayOverrides().getOverrideDay(d)) {
  15079. b += (" " + this.overriddenDayCls);
  15080. if (!this.getDayOverrides().isWorkingDay(d)) {
  15081. b += (" " + this.nonWorkingDayCls)
  15082. }
  15083. } else {
  15084. var e = null;
  15085. this.getWeekOverrides().each(function(h) {
  15086. if (Ext.Date.between(d, h.getStartDate(), h
  15087. .getEndDate())) {
  15088. e = h;
  15089. return true
  15090. }
  15091. });
  15092. if (e) {
  15093. b += (" " + this.overriddenWeekDayCls);
  15094. var c = new Date(d).getDay(), a = e.getAvailability();
  15095. if (a && a[c] && a[c].getIsWorkingDay() === false) {
  15096. b += (" " + g.nonWorkingDayCls)
  15097. }
  15098. } else {
  15099. if (!this.getDayOverrides().isWorkingDay(d)) {
  15100. b += (" " + this.nonWorkingDayCls)
  15101. }
  15102. }
  15103. }
  15104. return b.length > 0 ? b : this.workingDayCls
  15105. },
  15106. removeCustomCls : function() {
  15107. this.cells.removeCls([this.overriddenDayCls,
  15108. this.nonWorkingDayCls, this.workingDayCls,
  15109. this.overriddenWeekDayCls])
  15110. }
  15111. });
  15112. Ext.define("Gnt.widget.calendar.Calendar", {
  15113. extend : "Ext.form.Panel",
  15114. requires : ["Ext.XTemplate", "Gnt.data.Calendar",
  15115. "Gnt.widget.calendar.DayGrid", "Gnt.widget.calendar.WeekGrid",
  15116. "Gnt.widget.calendar.DayAvailabilityGrid",
  15117. "Gnt.widget.calendar.WeekEditor", "Gnt.widget.calendar.DatePicker"],
  15118. alias : "widget.calendar",
  15119. defaults : {
  15120. padding : 10,
  15121. border : false
  15122. },
  15123. workingDayCls : "gnt-datepicker-workingday",
  15124. nonWorkingDayCls : "gnt-datepicker-nonworkingday",
  15125. overriddenDayCls : "gnt-datepicker-overriddenday",
  15126. overriddenWeekDayCls : "gnt-datepicker-overriddenweekday",
  15127. calendar : null,
  15128. dayOverrideNameHeaderText : "Name",
  15129. dateText : "Date",
  15130. addText : "Add",
  15131. editText : "Edit",
  15132. removeText : "Remove",
  15133. workingDayText : "Working day",
  15134. weekendsText : "Weekends",
  15135. overriddenDayText : "Overridden day",
  15136. overriddenWeekText : "Overridden week",
  15137. defaultTimeText : "Default time",
  15138. workingTimeText : "Working time",
  15139. nonworkingTimeText : "Non-working time",
  15140. dayGridConfig : null,
  15141. weekGridConfig : null,
  15142. datePickerConfig : null,
  15143. dayOverridesText : "Day overrides",
  15144. weekOverridesText : "Week overrides",
  15145. okText : "OK",
  15146. cancelText : "Cancel",
  15147. calendarNameText : "Calendar name",
  15148. tplTexts : {
  15149. tplWorkingHours : "Working hours for",
  15150. tplIsNonWorking : "is non-working",
  15151. tplOverride : "override",
  15152. tplInCalendar : "in calendar",
  15153. tplDayInCalendar : "standard day in calendar"
  15154. },
  15155. parentCalendarText : "Parent calendar",
  15156. noParentText : "No parent",
  15157. selectParentText : "Select parent",
  15158. newDayName : "[Without name]",
  15159. overrideErrorText : "There is already an override for this day",
  15160. intersectDatesErrorText : "Dates shouldn't intersect",
  15161. startDateErrorText : "StartDate greater then EndDate",
  15162. dayGrid : null,
  15163. weekGrid : null,
  15164. getDayGrid : function() {
  15165. if (!this.dayGrid) {
  15166. this.dayGrid = Ext.create("Gnt.widget.calendar.DayGrid", Ext.apply(
  15167. {
  15168. tbar : [{
  15169. text : this.addText,
  15170. action : "add",
  15171. iconCls : "gnt-action-add",
  15172. handler : this.addDay,
  15173. scope : this
  15174. }, {
  15175. text : this.editText,
  15176. action : "edit",
  15177. iconCls : "gnt-action-edit",
  15178. handler : this.editDay,
  15179. scope : this
  15180. }, {
  15181. text : this.removeText,
  15182. action : "remove",
  15183. iconCls : "gnt-action-remove",
  15184. handler : this.removeDay,
  15185. scope : this
  15186. }]
  15187. }, this.dayGridConfig || {}))
  15188. }
  15189. return this.dayGrid
  15190. },
  15191. getWeekGrid : function() {
  15192. if (!this.weekGrid) {
  15193. this.weekGrid = Ext.create("Gnt.widget.calendar.WeekGrid", Ext
  15194. .apply({
  15195. tbar : [{
  15196. text : this.addText,
  15197. action : "add",
  15198. iconCls : "gnt-action-add",
  15199. handler : this.addWeek,
  15200. scope : this
  15201. }, {
  15202. text : this.editText,
  15203. action : "edit",
  15204. iconCls : "gnt-action-edit",
  15205. handler : this.editWeek,
  15206. scope : this
  15207. }, {
  15208. text : this.removeText,
  15209. action : "remove",
  15210. iconCls : "gnt-action-remove",
  15211. handler : this.removeWeek,
  15212. scope : this
  15213. }]
  15214. }, this.weekGridConfig || {}))
  15215. }
  15216. return this.weekGrid
  15217. },
  15218. datePicker : null,
  15219. getDatePicker : function() {
  15220. if (!this.datePicker) {
  15221. this.datePicker = Ext.create("Gnt.widget.calendar.DatePicker",
  15222. this.datePickerConfig || {})
  15223. }
  15224. return this.datePicker
  15225. },
  15226. legendTpl : '<ul class="gnt-calendar-legend"><li class="gnt-calendar-legend-item"><div class="gnt-calendar-legend-itemstyle {workingDayCls}"></div><span class="gnt-calendar-legend-itemname">{workingDayText}</span><div style="clear: both"></div></li><li><div class="gnt-calendar-legend-itemstyle {nonWorkingDayCls}"></div><span class="gnt-calendar-legend-itemname">{weekendsText}</span><div style="clear: both"></div></li><li class="gnt-calendar-legend-override"><div class="gnt-calendar-legend-itemstyle {overriddenDayCls}">31</div><span class="gnt-calendar-legend-itemname">{overriddenDayText}</span><div style="clear: both"></div></li><li class="gnt-calendar-legend-override"><div class="gnt-calendar-legend-itemstyle {overriddenWeekDayCls}">31</div><span class="gnt-calendar-legend-itemname">{overriddenWeekText}</span><div style="clear: both"></div></li></ul>',
  15227. dateInfoTpl : null,
  15228. initComponent : function() {
  15229. var d = this;
  15230. if (!(this.legendTpl instanceof Ext.Template)) {
  15231. this.legendTpl = new Ext.XTemplate(this.legendTpl)
  15232. }
  15233. if (!(this.dateInfoTpl instanceof Ext.Template)) {
  15234. this.dateInfoTpl = new Ext.XTemplate(this.dateInfoTpl)
  15235. }
  15236. if (!this.calendar) {
  15237. Ext.Error
  15238. .raise('Required attribute "calendar" is missed during initialization of `Gnt.widget.Calendar`')
  15239. }
  15240. d.setupTemplates();
  15241. var b = this.getWeekGrid(), a = this.getDayGrid(), c = this
  15242. .getDatePicker();
  15243. this.dayGrid.on({
  15244. selectionchange : this.onDayGridSelectionChange,
  15245. validateedit : this.onDayGridValidateEdit,
  15246. edit : this.onDayGridEdit,
  15247. scope : this
  15248. });
  15249. this.dayGrid.store.on({
  15250. update : this.refreshView,
  15251. remove : this.refreshView,
  15252. add : this.refreshView,
  15253. scope : this
  15254. });
  15255. this.weekGrid.on({
  15256. selectionchange : this.onWeekGridSelectionChange,
  15257. validateedit : this.onWeekGridValidateEdit,
  15258. edit : this.onWeekGridEdit,
  15259. scope : this
  15260. });
  15261. this.weekGrid.store.on({
  15262. update : this.refreshView,
  15263. remove : this.refreshView,
  15264. add : this.refreshView,
  15265. scope : this
  15266. });
  15267. this.datePicker.on({
  15268. select : this.onDateSelect,
  15269. scope : this
  15270. });
  15271. this.fillDaysStore();
  15272. this.fillWeeksStore();
  15273. c.setWeekOverrides(b.getStore());
  15274. c.setDayOverrides(a.getStore());
  15275. this.dateInfoPanel = new Ext.Panel({
  15276. cls : "gnt-calendar-dateinfo",
  15277. columnWidth : 0.33,
  15278. border : false,
  15279. height : 200
  15280. });
  15281. this.items = [{
  15282. xtype : "container",
  15283. layout : "hbox",
  15284. pack : "start",
  15285. align : "stretch",
  15286. items : [{
  15287. html : Ext.String.format('{0}: "{1}"', this.calendarNameText,
  15288. this.calendar.name),
  15289. border : false,
  15290. flex : 1
  15291. }, {
  15292. xtype : "combobox",
  15293. name : "cmb_parentCalendar",
  15294. fieldLabel : d.parentCalendarText,
  15295. store : Ext.create("Ext.data.Store", {
  15296. fields : ["Id", "Name"],
  15297. data : [{
  15298. Id : -1,
  15299. Name : d.noParentText
  15300. }].concat(d.calendar
  15301. .getParentableCalendars())
  15302. }),
  15303. queryMode : "local",
  15304. displayField : "Name",
  15305. valueField : "Id",
  15306. editable : false,
  15307. emptyText : d.selectParentText,
  15308. value : d.calendar.parent ? d.calendar.parent.calendarId : -1,
  15309. flex : 1
  15310. }]
  15311. }, {
  15312. layout : "column",
  15313. defaults : {
  15314. border : false
  15315. },
  15316. items : [{
  15317. margin : "0 15px 0 0",
  15318. columnWidth : 0.3,
  15319. html : this.legendTpl.apply({
  15320. workingDayText : this.workingDayText,
  15321. weekendsText : this.weekendsText,
  15322. overriddenDayText : this.overriddenDayText,
  15323. overriddenWeekText : this.overriddenWeekText,
  15324. workingDayCls : this.workingDayCls,
  15325. nonWorkingDayCls : this.nonWorkingDayCls,
  15326. overriddenDayCls : this.overriddenDayCls,
  15327. overriddenWeekDayCls : this.overriddenWeekDayCls
  15328. })
  15329. }, {
  15330. columnWidth : 0.37,
  15331. margin : "0 5px 0 0",
  15332. items : c
  15333. }, this.dateInfoPanel]
  15334. }, {
  15335. xtype : "tabpanel",
  15336. items : [a, b]
  15337. }];
  15338. this.callParent(arguments)
  15339. },
  15340. setupTemplates : function() {
  15341. var a = this, b = [a.tplTexts[0], a.tplTexts[1], a.tplTexts[2],
  15342. a.tplTexts[3], a.tplTexts[4]];
  15343. this.dateInfoTpl = this.dateInfoTpl
  15344. || Ext.String.format(['<tpl if="isWorkingDay == true">',
  15345. "<div>{0} {date}:</div>", "</tpl>",
  15346. '<tpl if="isWorkingDay == false">',
  15347. "<div>{date} {1}</div>", "</tpl>",
  15348. '<ul class="gnt-calendar-availabilities">',
  15349. '<tpl for="availability">', "<li>{.}</li>",
  15350. "</tpl>", "</ul>", "<span>Based on: ",
  15351. '<tpl if="override == true">',
  15352. '{2} "{name}" {3} "{calendarName}"', "</tpl>",
  15353. '<tpl if="override == false">',
  15354. '{4} "{calendarName}"', "</tpl>", "</span>"]
  15355. .join(""), b)
  15356. },
  15357. onRender : function() {
  15358. this.onDateSelect(this.getDatePicker(), new Date());
  15359. this.callParent(arguments)
  15360. },
  15361. fillDaysStore : function() {
  15362. var a = [];
  15363. this.calendar.each(function(b) {
  15364. if (!b.getDate()) {
  15365. return
  15366. }
  15367. a.push(Ext.create("Gnt.model.CalendarDay", {
  15368. Date : b.getDate(),
  15369. Id : b.getId(),
  15370. Name : b.getName(),
  15371. IsWorkingDay : b.getIsWorkingDay(),
  15372. Availability : b.getAvailability()
  15373. }))
  15374. });
  15375. this.getDayGrid().getStore().loadData(a)
  15376. },
  15377. fillWeeksStore : function() {
  15378. var d = [], c = this, b = this.getWeekGrid().store.model.prototype, a;
  15379. Ext.Array.each(this.calendar.nonStandardWeeksStartDates, function(f) {
  15380. var h = c.calendar.getNonStandardWeekByStartDate(f);
  15381. var g = {};
  15382. var e = c.calendar.getDefaultWeekAvailability();
  15383. g[b.nameField] = h.name;
  15384. g[b.startDateField] = h.startDate;
  15385. g[b.endDateField] = h.endDate;
  15386. g[b.availabilityField] = e;
  15387. Ext.Array.each(e, function(i) {
  15388. i.setName(h.name);
  15389. i.clearDate(null)
  15390. });
  15391. Ext.Array.each(h.weekAvailability, function(k, l) {
  15392. if (k) {
  15393. var m = k.getId();
  15394. var j = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
  15395. .exec(m);
  15396. if (!j) {
  15397. return
  15398. }
  15399. var i = j[1];
  15400. a = Ext.create("Gnt.model.CalendarDay");
  15401. a.clearDate(null);
  15402. a.setId(m);
  15403. a.setName(h.name);
  15404. a.setIsWorkingDay(k.getIsWorkingDay());
  15405. a.setAvailability(k.getAvailability())
  15406. } else {
  15407. a = c.calendar.getDefaultCalendarDay(l)
  15408. }
  15409. e[l] = a
  15410. });
  15411. d.push(g)
  15412. });
  15413. this.getWeekGrid().getStore().loadData(d)
  15414. },
  15415. reload : function() {
  15416. var b = this.getWeekGrid(), a = this.getDayGrid();
  15417. this.fillDaysStore();
  15418. this.fillWeeksStore();
  15419. this.getDatePicker().setWeekOverrides(b.getStore());
  15420. this.getDatePicker().setDayOverrides(a.getStore())
  15421. },
  15422. editDay : function() {
  15423. var c = this, e = this.getDayGrid().getSelectionModel();
  15424. if (!e || e.getSelection().length === 0) {
  15425. return
  15426. }
  15427. var a = e.getSelection()[0];
  15428. var b = new Gnt.widget.calendar.DayAvailabilityGrid({
  15429. addText : this.addText,
  15430. removeText : this.removeText,
  15431. workingTimeText : this.workingTimeText,
  15432. nonworkingTimeText : this.nonworkingTimeText
  15433. });
  15434. var d = Ext.create("Ext.window.Window", {
  15435. title : this.dayOverridesText,
  15436. modal : true,
  15437. width : 280,
  15438. height : 260,
  15439. layout : "fit",
  15440. items : b,
  15441. buttons : [{
  15442. text : this.okText,
  15443. handler : function() {
  15444. c.calendar.clearCache();
  15445. if (b.isValid()) {
  15446. var f = b.calendarDay;
  15447. f.setIsWorkingDay(b.isWorkingDay());
  15448. f.setAvailability(b.getIntervals());
  15449. c.applyCalendarDay(f, a);
  15450. c.refreshView();
  15451. d.close()
  15452. }
  15453. }
  15454. }, {
  15455. text : this.cancelText,
  15456. handler : function() {
  15457. d.close()
  15458. }
  15459. }]
  15460. });
  15461. b.editAvailability(this.cloneCalendarDay(a));
  15462. d.show()
  15463. },
  15464. addDay : function() {
  15465. var a = this.getDatePicker().getValue(), b = this.getDayGrid(), c = Ext
  15466. .create("Gnt.model.CalendarDay", {
  15467. Name : this.newDayName,
  15468. Cls : this.calendar.defaultNonWorkingTimeCssCls,
  15469. Date : a,
  15470. IsWorkingDay : false
  15471. });
  15472. b.getStore().insert(0, c);
  15473. b.getSelectionModel().select([c], false, false)
  15474. },
  15475. removeDay : function() {
  15476. var f = this.getDayGrid(), h = f.getSelectionModel(), c = f.getStore();
  15477. if (!h || h.getSelection().length === 0) {
  15478. return
  15479. }
  15480. c.clearCache();
  15481. var a = h.getSelection()[0], d = this.getDatePicker().getValue(), g = d
  15482. .getDay(), b = this.getWeekOverrideDay(d), e = b != null;
  15483. c.remove(a);
  15484. if (b == null) {
  15485. b = this.calendar.defaultWeekAvailability[g]
  15486. }
  15487. this.getDatePicker().setValue(d)
  15488. },
  15489. refreshView : function() {
  15490. var e = this.getDatePicker().getValue(), b = this.getCalendarDay(e), d = this
  15491. .getWeekGrid(), a = this.getDayGrid(), c = a.getStore()
  15492. .getOverrideDay(e), g;
  15493. if (c) {
  15494. a.getSelectionModel().select([c], false, true)
  15495. } else {
  15496. g = this.getWeekOverrideByDate(e);
  15497. if (g) {
  15498. d.getSelectionModel().select([g], false, true)
  15499. }
  15500. }
  15501. var f = {
  15502. name : b.getName(),
  15503. date : Ext.Date.format(e, "M j, Y"),
  15504. calendarName : this.calendar.name || this.calendar.calendarId,
  15505. availability : b.getAvailability(true),
  15506. override : !!(c || g),
  15507. isWorkingDay : b.getIsWorkingDay()
  15508. };
  15509. this.dateInfoPanel.update(this.dateInfoTpl.apply(f))
  15510. },
  15511. onDayGridSelectionChange : function(d) {
  15512. if (!d || d.getSelection().length === 0) {
  15513. return
  15514. }
  15515. var a = d.getSelection()[0], b = a.getDate(), c = this.getDayGrid();
  15516. this.getDatePicker().setValue(b)
  15517. },
  15518. onDayGridEdit : function(b, c) {
  15519. if (c.field === "Date") {
  15520. var a = Ext.Date.clearTime(c.value, true);
  15521. c.record.data[c.record.idProperty] = a - 0;
  15522. c.grid.getStore().clearCache();
  15523. this.getDatePicker().setValue(c.value)
  15524. }
  15525. this.refreshView()
  15526. },
  15527. onDayGridValidateEdit : function(b, c) {
  15528. var a = c.grid.getStore();
  15529. if (c.field === a.model.prototype.dateField
  15530. && a.getOverrideDay(c.value) && c.value !== c.originalValue) {
  15531. Ext.MessageBox.alert("Error", this.overrideErrorText);
  15532. return false
  15533. }
  15534. },
  15535. onDateSelect : function(b, a) {
  15536. this.refreshView()
  15537. },
  15538. getCalendarDay : function(b) {
  15539. var a = this.getOverrideDay(b);
  15540. if (a) {
  15541. return a
  15542. }
  15543. a = this.getWeekOverrideDay(b);
  15544. if (a) {
  15545. return a
  15546. }
  15547. return this.calendar.defaultWeekAvailability[b.getDay()]
  15548. },
  15549. getOverrideDay : function(a) {
  15550. return this.getDayGrid().getStore().getOverrideDay(a)
  15551. },
  15552. getWeekOverrideDay : function(c) {
  15553. var e = new Date(c), d = this.getWeekOverrideByDate(c), b = e.getDay();
  15554. if (d == null) {
  15555. return null
  15556. }
  15557. var a = d.getAvailability();
  15558. if (!a) {
  15559. return null
  15560. }
  15561. return a[b]
  15562. },
  15563. getWeekOverrideByDate : function(a) {
  15564. var b = null;
  15565. this.getWeekGrid().getStore().each(function(c) {
  15566. if (Ext.Date.between(a, c.getStartDate(), c.getEndDate())) {
  15567. b = c;
  15568. return true
  15569. }
  15570. });
  15571. return b
  15572. },
  15573. editWeek : function() {
  15574. var f = this.getWeekGrid().getSelectionModel(), c = this;
  15575. if (!f || f.getSelection().length === 0) {
  15576. return
  15577. }
  15578. var b = f.getSelection()[0];
  15579. var a = new Gnt.widget.calendar.WeekEditor({
  15580. getDefaultWeekAvailabilityHandler : function() {
  15581. return c.getDefaultWeekAvailability()
  15582. }
  15583. });
  15584. var e = Ext.create("Ext.window.Window", {
  15585. title : this.weekOverridesText,
  15586. modal : true,
  15587. width : 370,
  15588. defaults : {
  15589. border : false
  15590. },
  15591. layout : "fit",
  15592. items : a,
  15593. buttons : [{
  15594. text : this.okText,
  15595. handler : function() {
  15596. c.calendar.clearCache();
  15597. a.applyChanges(function(g) {
  15598. b.setAvailability(g);
  15599. var i = c.getDatePicker().getValue(), h = g[i.getDay()];
  15600. c.refreshView();
  15601. e.close()
  15602. })
  15603. }
  15604. }, {
  15605. text : this.cancelText,
  15606. handler : function() {
  15607. e.close()
  15608. }
  15609. }]
  15610. });
  15611. var d = [];
  15612. Ext.Array.each(b.getAvailability(), function(g) {
  15613. d.push(c.cloneCalendarDay(g))
  15614. });
  15615. e.show();
  15616. e.down("calendarweekeditor").editAvailability(b.getStartDate(),
  15617. b.getEndDate(), d)
  15618. },
  15619. addWeek : function() {
  15620. var a = this.getWeekGrid().getStore();
  15621. var b = this.getDatePicker().getValue(), c = new a.model();
  15622. c.setName(this.newDayName);
  15623. c.setStartDate(b);
  15624. c.setEndDate(b);
  15625. c.setAvailability(this.calendar.getDefaultWeekAvailability());
  15626. a.insert(0, c);
  15627. this.getWeekGrid().getSelectionModel().select([c], false, false)
  15628. },
  15629. removeWeek : function() {
  15630. var f = this.getWeekGrid().getSelectionModel();
  15631. if (!f || f.getSelection().length === 0) {
  15632. return
  15633. }
  15634. var a = f.getSelection()[0], c = this.getDatePicker().getValue(), e = c
  15635. .getDay(), b = this.getOverrideDay(c), d = !!b;
  15636. b = b || this.calendar.defaultWeekAvailability[e];
  15637. this.getWeekGrid().getStore().remove(a);
  15638. this.getDatePicker().setValue(c);
  15639. this.refreshView()
  15640. },
  15641. onWeekGridSelectionChange : function(c) {
  15642. if (!c || c.getSelection().length === 0) {
  15643. return
  15644. }
  15645. var a = c.getSelection()[0], b = a.getStartDate();
  15646. this.getDatePicker().setValue(b)
  15647. },
  15648. onWeekGridEdit : function(f, g) {
  15649. var c = g.record, a = c.getStartDate(), d = c.getEndDate(), b = c
  15650. .getAvailability(), j = g.grid.getStore().model.prototype;
  15651. if (g.field == j.startDateField || g.field == j.endDateField) {
  15652. var h = Ext.Date.format(a, "Y/m/d");
  15653. var i = Ext.Date.format(d, "Y/m/d");
  15654. Ext.Array.each(b, function(k) {
  15655. var l = k.getId();
  15656. var e = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
  15657. .exec(l);
  15658. if (!e) {
  15659. return
  15660. }
  15661. k.set("Id", Ext.String
  15662. .format("{0}-{1}-{2}", e[1], h, i))
  15663. });
  15664. this.getDatePicker().setValue(a)
  15665. }
  15666. this.refreshView()
  15667. },
  15668. onWeekGridValidateEdit : function(d, f) {
  15669. var g = this, b = f.record, a = b.getStartDate(), c = b.getEndDate(), h = true, i = f.grid
  15670. .getStore(), j = i.model.prototype;
  15671. if ((f.field === j.startDateField && c < f.value || f.field === j.endDateField
  15672. && a > f.value)) {
  15673. Ext.MessageBox.alert("Error", g.startDateErrorText);
  15674. return false
  15675. }
  15676. i.each(function(k) {
  15677. var l = k.getStartDate(), e = k.getEndDate();
  15678. if (l == a && e == c) {
  15679. return
  15680. }
  15681. if ((f.field == j.startDateField && l < a && f.value <= e)
  15682. || (f.field == j.endDateField && e > c && f.value >= l)) {
  15683. h = false;
  15684. return true
  15685. }
  15686. });
  15687. if (!h) {
  15688. Ext.MessageBox.alert("Error", g.intersectDatesErrorText);
  15689. return false
  15690. }
  15691. },
  15692. applyChanges : function(b) {
  15693. var a = this.down('combobox[name="cmb_parentCalendar"]').getValue();
  15694. this.calendar.parent = a ? Gnt.data.Calendar.getCalendar(a) : null;
  15695. this.calendar.proxy.extraParams.parentId = this.calendar.parent
  15696. ? this.calendar.parent.calendarId
  15697. : null;
  15698. this.applyDays();
  15699. this.applyWeeks();
  15700. if (b && Ext.isFunction(b)) {
  15701. b.call(this, this.calendar)
  15702. }
  15703. },
  15704. applyCalendarDay : function(b, a) {
  15705. a.beginEdit();
  15706. a.setId(b.getId());
  15707. a.setName(b.getName());
  15708. a.setIsWorkingDay(b.getIsWorkingDay());
  15709. a.setDate(b.getDate());
  15710. a.setAvailability(b.getAvailability());
  15711. a.endEdit()
  15712. },
  15713. applyWeek : function(d, c) {
  15714. var b = this, a = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/;
  15715. Ext.Array.each(d.getAvailability(), function(f, h) {
  15716. var i = false, g = f.getId(), e = a.exec(g) ? false : true;
  15717. Ext.Array.each(c.weekAvailability, function(j) {
  15718. var l = j.getId(), k = a.exec(l);
  15719. if (k[1] == h) {
  15720. if (e) {
  15721. b.calendar.remove(j)
  15722. } else {
  15723. b.applyCalendarDay(f, j)
  15724. }
  15725. i = true;
  15726. return i
  15727. }
  15728. });
  15729. if (!i && !e) {
  15730. b.calendar.add(f)
  15731. }
  15732. })
  15733. },
  15734. applyWeeks : function() {
  15735. var c = this, b = this.getWeekGrid().getStore(), a = [], e = [], d = [];
  15736. Ext.Array.each(this.calendar.nonStandardWeeksStartDates, function(f) {
  15737. var g = false;
  15738. b.each(function(i) {
  15739. var h = Ext.Date.clearTime(i.getStartDate());
  15740. if (h === f) {
  15741. var j = c.calendar
  15742. .getNonStandardWeekByDate(f);
  15743. j.endDate == i.getEndDate() ? e
  15744. .push([i, j]) : a.push(f);
  15745. g = true;
  15746. return true
  15747. }
  15748. });
  15749. if (!g) {
  15750. a.push(f)
  15751. }
  15752. });
  15753. b.each(function(f) {
  15754. if (c.calendar
  15755. .getNonStandardWeekByDate(f.getStartDate() == null)) {
  15756. d.push(f)
  15757. }
  15758. });
  15759. Ext.Array.each(a, function(f) {
  15760. c.calendar.removeNonStandardWeek(f)
  15761. });
  15762. Ext.Array.each(d, function(f) {
  15763. c.calendar.addNonStandardWeek(f.getStartDate(), f
  15764. .getEndDate(), f.getAvailability())
  15765. });
  15766. Ext.Array.each(e, function(f) {
  15767. c.applyWeek(f[0], f[1])
  15768. })
  15769. },
  15770. applyDays : function() {
  15771. var c = this, b = this.getDayGrid().getStore(), a = [], e = [], d = [];
  15772. this.calendar.each(function(f) {
  15773. var g = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
  15774. .exec(f.getId());
  15775. if (g) {
  15776. return
  15777. }
  15778. b.getOverrideDay(f.getDate()) == null ? a.push(f) : e
  15779. .push(f)
  15780. });
  15781. b.each(function(f) {
  15782. if (c.calendar.getOverrideDay(f.getDate()) == null) {
  15783. d.push(f)
  15784. }
  15785. });
  15786. this.calendar.remove(a);
  15787. this.calendar.add(d);
  15788. Ext.Array.each(e, function(f) {
  15789. var g = b.getOverrideDay(f.getDate());
  15790. c.applyCalendarDay(g, f)
  15791. })
  15792. },
  15793. cloneCalendarDay : function(a) {
  15794. return Ext.create("Gnt.model.CalendarDay", {
  15795. Date : a.getDate(),
  15796. Id : a.getId(),
  15797. Name : a.getName(),
  15798. IsWorkingDay : a.getIsWorkingDay(),
  15799. Availability : a.getAvailability()
  15800. })
  15801. },
  15802. getDefaultWeekAvailability : function() {
  15803. return this.calendar.defaultWeekAvailability
  15804. },
  15805. onDestroy : function() {
  15806. this.getWeekGrid().destroy();
  15807. this.getDayGrid().destroy();
  15808. this.getDatePicker().destroy();
  15809. this.callParent(arguments)
  15810. }
  15811. });
  15812. Ext.onReady(function() {
  15813. /*if (window.location.href.match("bryntum.com|ext-scheduler.com")) {
  15814. return
  15815. } else {
  15816. if (Sch && Sch.view && Sch.view.TimelineGridView) {
  15817. var b = false;
  15818. Sch.view.TimelineGridView.override({
  15819. refresh : function() {
  15820. this.callOverridden(arguments);
  15821. if (b || !this.rendered) {
  15822. return
  15823. }
  15824. b = true;
  15825. Ext.Function.defer(function() {
  15826. this.el.select(this.eventSelector)
  15827. .setOpacity(0.15)
  15828. }, 10 * 60 * 1000, this);
  15829. var c = this.el.parent().createChild({
  15830. //tag : "a",
  15831. //href : "http://www.bryntum.com/store",
  15832. //title : "Click here to purchase a license",
  15833. //style : "display:block;height:54px;width:230px;background: #fff url(http://www.bryntum.com/site-images/bryntum-trial.png) no-repeat;z-index:10000;border:1px solid #ddd;-webkit-box-shadow: 2px 2px 2px rgba(100, 100, 100, 0.5);-moz-box-shadow: 2px 2px 2px rgba(100, 100, 100, 0.5);-moz-border-radius:5px;-webkit-border-radius:5px;position:absolute;bottom:10px;right:15px;"
  15834. });
  15835. try {
  15836. if (!Ext.util.Cookies.get("bmeval")) {
  15837. Ext.util.Cookies.set("bmeval",
  15838. new Date().getTime(), Ext.Date.add(
  15839. new Date(), Ext.Date.YEAR, 2))
  15840. } else {
  15841. var g = Ext.util.Cookies.get("bmeval"), d = new Date(parseInt(
  15842. g, 10));
  15843. if (Ext.Date.add(d, Ext.Date.DAY, 45) < new Date()) {
  15844. this.el.select(this.eventSelector).hide();
  15845. this.el.mask("Trial Period Expired!").setStyle(
  15846. "z-index", 10000);
  15847. this.refresh = Ext.emptyFn
  15848. }
  15849. }
  15850. } catch (f) {
  15851. }
  15852. }
  15853. })
  15854. }
  15855. if (Sch && Sch.view && Sch.view.TimelineTreeView) {
  15856. var a = false;
  15857. Sch.view.TimelineTreeView.override({
  15858. refresh : function() {
  15859. this.callOverridden(arguments);
  15860. if (a || !this.rendered) {
  15861. return
  15862. }
  15863. a = true;
  15864. Ext.Function.defer(function() {
  15865. this.el.select(this.eventSelector)
  15866. .setOpacity(0.15)
  15867. }, 10 * 60 * 1000, this);
  15868. var c = this.el.parent().createChild({
  15869. tag : "a",
  15870. //href : "http://www.bryntum.com/store",
  15871. //title : "Click here to purchase a license",
  15872. //style : "display:block;height:54px;width:230px;background: #fff url(http://www.bryntum.com/site-images/bryntum-trial.png) no-repeat;z-index:10000;border:1px solid #ddd;-webkit-box-shadow: 2px 2px 2px rgba(100, 100, 100, 0.5);-moz-box-shadow: 2px 2px 2px rgba(100, 100, 100, 0.5);-moz-border-radius:5px;-webkit-border-radius:5px;position:absolute;bottom:10px;right:15px;"
  15873. });
  15874. Ext.Function.defer(c.fadeOut, 10000, c);
  15875. try {
  15876. if (!Ext.util.Cookies.get("bmeval")) {
  15877. Ext.util.Cookies.set("bmeval",
  15878. new Date().getTime(), Ext.Date.add(
  15879. new Date(), Ext.Date.YEAR, 2))
  15880. } else {
  15881. var g = Ext.util.Cookies.get("bmeval"), d = new Date(parseInt(
  15882. g, 10));
  15883. if (Ext.Date.add(d, Ext.Date.DAY, 45) < new Date()) {
  15884. this.el.select(this.eventSelector).hide();
  15885. this.el.mask("Trial Period Expired!").setStyle(
  15886. "z-index", 10000);
  15887. this.refresh = Ext.emptyFn
  15888. }
  15889. }
  15890. } catch (f) {
  15891. }
  15892. }
  15893. })
  15894. }
  15895. }*/
  15896. });
  15897. Ext.data.Connection.override({
  15898. parseStatus : function(b) {
  15899. var a = this.callOverridden(arguments);
  15900. if (b === 0) {
  15901. a.success = true
  15902. }
  15903. return a
  15904. }
  15905. });