gnt-all-debug.js 413 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831
  1. /*
  2. *
  3. * 2.1.11
  4. *
  5. */
  6. Ext.define("Sch.util.Patch", {
  7. target : null,
  8. minVersion : null,
  9. maxVersion : null,
  10. reportUrl : null,
  11. description : null,
  12. applyFn : null,
  13. ieOnly : false,
  14. onClassExtended : function(a, b) {
  15. if (Sch.disableOverrides) {
  16. return
  17. }
  18. if (b.ieOnly && !Ext.isIE) {
  19. return
  20. }
  21. if ((!b.minVersion || Ext.versions.extjs.equals(b.minVersion) || Ext.versions.extjs
  22. .isGreaterThan(b.minVersion))
  23. && (!b.maxVersion || Ext.versions.extjs.equals(b.maxVersion) || Ext.versions.extjs
  24. .isLessThan(b.maxVersion))) {
  25. if (b.applyFn) {
  26. b.applyFn()
  27. } else {
  28. b.requires[0].override(b.overrides)
  29. }
  30. }
  31. }
  32. });
  33. Ext.define("Sch.patches.LoadMask", {
  34. extend : "Sch.util.Patch",
  35. requires : ["Ext.view.AbstractView"],
  36. minVersion : "4.1.0b3",
  37. reportURL : "http://www.sencha.com/forum/showthread.php?187700-4.1.0-B3-Ext.AbstractView-no-longer-binds-its-store-to-load-mask",
  38. description : "In Ext4.1 loadmask no longer bind the store",
  39. overrides : {}
  40. });
  41. Ext.define("Sch.patches.Table", {
  42. extend : "Sch.util.Patch",
  43. requires : ["Ext.view.Table"],
  44. minVersion : "4.1.1",
  45. maxVersion : "4.1.1",
  46. reportURL : "http://www.sencha.com/forum/showthread.php?238026-4.1.1-Alt-row-styling-lost-after-record-update&p=874190#post874190",
  47. description : "In Ext4.1.1 when record is updated, the alternate row styling is lost",
  48. overrides : {
  49. onUpdate : function(c, a, b, e) {
  50. var d = this.store.indexOf(a);
  51. this.callParent(arguments);
  52. this.doStripeRows(d, d)
  53. }
  54. }
  55. });
  56. Ext.define("Sch.patches.TreeView", {
  57. extend : "Sch.util.Patch",
  58. requires : ["Ext.tree.View"],
  59. maxVersion : "4.1.3",
  60. applyFn : function() {
  61. Ext.tree.View.addMembers({
  62. providedStore : null,
  63. initComponent : function() {
  64. var a = this, b = a.panel.getStore();
  65. if (a.initialConfig.animate === undefined) {
  66. a.animate = Ext.enableFx
  67. }
  68. a.store = a.providedStore
  69. || new Ext.data.NodeStore({
  70. treeStore : b,
  71. recursive : true,
  72. rootVisible : a.rootVisible
  73. });
  74. a.store.on({
  75. beforeexpand : a.onBeforeExpand,
  76. expand : a.onExpand,
  77. beforecollapse : a.onBeforeCollapse,
  78. collapse : a.onCollapse,
  79. write : a.onStoreWrite,
  80. datachanged : a.onStoreDataChanged,
  81. collapsestart : a.beginBulkUpdate,
  82. collapsecomplete : a.endBulkUpdate,
  83. scope : a
  84. });
  85. if (Ext.versions.extjs
  86. .isGreaterThanOrEqual("4.1.2")) {
  87. a.mon(b, {
  88. scope : a,
  89. beforefill : a.onBeforeFill,
  90. fillcomplete : a.onFillComplete,
  91. beforebulkremove : a.beginBulkUpdate,
  92. bulkremovecomplete : a.endBulkUpdate
  93. });
  94. if (!b.remoteSort) {
  95. a.mon(b, {
  96. scope : a,
  97. beforesort : a.onBeforeSort,
  98. sort : a.onSort
  99. })
  100. }
  101. }
  102. if (a.node && !a.store.node) {
  103. a.setRootNode(a.node)
  104. }
  105. a.animQueue = {};
  106. a.animWraps = {};
  107. a.addEvents("afteritemexpand",
  108. "afteritemcollapse");
  109. a.callParent(arguments);
  110. a.on({
  111. element : "el",
  112. scope : a,
  113. delegate : a.expanderSelector,
  114. mouseover : a.onExpanderMouseOver,
  115. mouseout : a.onExpanderMouseOut
  116. });
  117. a.on({
  118. element : "el",
  119. scope : a,
  120. delegate : a.checkboxSelector,
  121. click : a.onCheckboxChange
  122. })
  123. }
  124. })
  125. }
  126. });
  127. Ext.define("Sch.patches.DataOperation", {
  128. extend : "Sch.util.Patch",
  129. requires : ["Ext.data.Operation"],
  130. reportURL : "http://www.sencha.com/forum/showthread.php?198894-4.1-Ext.data.TreeStore-CRUD-regression.",
  131. description : "In Ext 4.1.0 newly created records do not get the Id returned by server applied",
  132. maxVersion : "4.1.0",
  133. overrides : {
  134. commitRecords : function(j) {
  135. var g = this, h, f, a, c, b, d, e;
  136. if (!g.actionSkipSyncRe.test(g.action)) {
  137. a = g.records;
  138. if (a && a.length) {
  139. if (a.length > 1) {
  140. if (g.action == "update" || a[0].clientIdProperty) {
  141. h = new Ext.util.MixedCollection();
  142. h.addAll(j);
  143. for (f = a.length; f--;) {
  144. b = a[f];
  145. c = h.findBy(g.matchClientRec, b);
  146. b.copyFrom(c)
  147. }
  148. } else {
  149. for (d = 0, e = a.length; d < e; ++d) {
  150. b = a[d];
  151. c = j[d];
  152. if (b && c) {
  153. g.updateRecord(b, c)
  154. }
  155. }
  156. }
  157. } else {
  158. this.updateRecord(a[0], j[0])
  159. }
  160. if (g.actionCommitRecordsRe.test(g.action)) {
  161. for (f = a.length; f--;) {
  162. a[f].commit()
  163. }
  164. }
  165. }
  166. }
  167. },
  168. updateRecord : function(a, b) {
  169. if (b && (a.phantom || a.getId() === b.getId())) {
  170. a.copyFrom(b)
  171. }
  172. }
  173. }
  174. });
  175. Ext.define("Sch.patches.TreeStore", {
  176. extend : "Sch.util.Patch",
  177. requires : ["Ext.data.TreeStore"],
  178. description : "http://www.sencha.com/forum/showthread.php?208602-Model-s-Id-field-not-defined-after-sync-in-TreeStore-%28CRUD%29",
  179. maxVersion : "4.1.0",
  180. overrides : {
  181. onCreateRecords : function(c) {
  182. this.callParent(arguments);
  183. var d = 0, b = c.length, a = this.tree, e;
  184. for (; d < b; ++d) {
  185. e = c[d];
  186. a.onNodeIdChanged(e, null, e.getId())
  187. }
  188. },
  189. setRootNode : function(a, e) {
  190. var d = this, c = d.model, b = c.prototype.idProperty;
  191. a = a || {};
  192. if (!a.isModel) {
  193. Ext.applyIf(a, {
  194. text : "Root",
  195. allowDrag : false
  196. });
  197. if (a[b] === undefined) {
  198. a[b] = d.defaultRootId
  199. }
  200. Ext.data.NodeInterface.decorate(c);
  201. a = Ext.ModelManager.create(a, c)
  202. } else {
  203. if (a.isModel && !a.isNode) {
  204. Ext.data.NodeInterface.decorate(c)
  205. }
  206. }
  207. d.getProxy().getReader().buildExtractors(true);
  208. d.tree.setRootNode(a);
  209. if (e !== true && !a.isLoaded()
  210. && (d.autoLoad === true || a.isExpanded())) {
  211. d.load({
  212. node : a
  213. })
  214. }
  215. return a
  216. }
  217. }
  218. });
  219. Ext.define("Sch.util.Date", {
  220. requires : "Ext.Date",
  221. singleton : true,
  222. unitHash : null,
  223. unitsByName : {},
  224. unitNames : {
  225. YEAR : {
  226. single : "year",
  227. plural : "years",
  228. abbrev : "yr"
  229. },
  230. QUARTER : {
  231. single : "quarter",
  232. plural : "quarters",
  233. abbrev : "q"
  234. },
  235. MONTH : {
  236. single : "month",
  237. plural : "months",
  238. abbrev : "mon"
  239. },
  240. WEEK : {
  241. single : "week",
  242. plural : "weeks",
  243. abbrev : "w"
  244. },
  245. DAY : {
  246. single : "day",
  247. plural : "days",
  248. abbrev : "d"
  249. },
  250. HOUR : {
  251. single : "hour",
  252. plural : "hours",
  253. abbrev : "h"
  254. },
  255. MINUTE : {
  256. single : "minute",
  257. plural : "minutes",
  258. abbrev : "min"
  259. },
  260. SECOND : {
  261. single : "second",
  262. plural : "seconds",
  263. abbrev : "s"
  264. },
  265. MILLI : {
  266. single : "ms",
  267. plural : "ms",
  268. abbrev : "ms"
  269. }
  270. },
  271. constructor : function() {
  272. var a = Ext.Date;
  273. var c = this.unitHash = {
  274. MILLI : a.MILLI,
  275. SECOND : a.SECOND,
  276. MINUTE : a.MINUTE,
  277. HOUR : a.HOUR,
  278. DAY : a.DAY,
  279. WEEK : "w",
  280. MONTH : a.MONTH,
  281. QUARTER : "q",
  282. YEAR : a.YEAR
  283. };
  284. Ext.apply(this, c);
  285. var b = this;
  286. this.units = [b.MILLI, b.SECOND, b.MINUTE, b.HOUR, b.DAY,
  287. b.WEEK, b.MONTH, b.QUARTER, b.YEAR];
  288. this.setUnitNames(this.unitNames)
  289. },
  290. setUnitNames : function(e) {
  291. var d = this.unitsByName = {};
  292. this.unitNames = e;
  293. var b = this.unitHash;
  294. for (var a in b) {
  295. if (b.hasOwnProperty(a)) {
  296. var c = b[a];
  297. e[c] = e[a];
  298. d[a] = c;
  299. d[c] = c
  300. }
  301. }
  302. },
  303. betweenLesser : function(b, d, a) {
  304. var c = b.getTime();
  305. return d.getTime() <= c && c < a.getTime()
  306. },
  307. constrain : function(b, c, a) {
  308. return this.min(this.max(b, c), a)
  309. },
  310. compareUnits : function(c, b) {
  311. var a = Ext.Array.indexOf(this.units, c), d = Ext.Array
  312. .indexOf(this.units, b);
  313. return a > d ? 1 : (a < d ? -1 : 0)
  314. },
  315. isUnitGreater : function(b, a) {
  316. return this.compareUnits(b, a) > 0
  317. },
  318. copyTimeValues : function(b, a) {
  319. b.setHours(a.getHours());
  320. b.setMinutes(a.getMinutes());
  321. b.setSeconds(a.getSeconds());
  322. b.setMilliseconds(a.getMilliseconds())
  323. },
  324. add : function(b, c, e) {
  325. var f = Ext.Date.clone(b);
  326. if (!c || e === 0) {
  327. return f
  328. }
  329. switch (c.toLowerCase()) {
  330. case this.MILLI :
  331. f = new Date(b.getTime() + e);
  332. break;
  333. case this.SECOND :
  334. f = new Date(b.getTime() + (e * 1000));
  335. break;
  336. case this.MINUTE :
  337. f = new Date(b.getTime() + (e * 60000));
  338. break;
  339. case this.HOUR :
  340. f = new Date(b.getTime() + (e * 3600000));
  341. break;
  342. case this.DAY :
  343. f.setDate(b.getDate() + e);
  344. break;
  345. case this.WEEK :
  346. f.setDate(b.getDate() + e * 7);
  347. break;
  348. case this.MONTH :
  349. var a = b.getDate();
  350. if (a > 28) {
  351. a = Math.min(a,
  352. Ext.Date.getLastDateOfMonth(this.add(
  353. Ext.Date.getFirstDateOfMonth(b),
  354. this.MONTH, e)).getDate())
  355. }
  356. f.setDate(a);
  357. f.setMonth(f.getMonth() + e);
  358. break;
  359. case this.QUARTER :
  360. f = this.add(b, this.MONTH, e * 3);
  361. break;
  362. case this.YEAR :
  363. f.setFullYear(b.getFullYear() + e);
  364. break
  365. }
  366. return f
  367. },
  368. getMeasuringUnit : function(a) {
  369. if (a === this.WEEK) {
  370. return this.DAY
  371. }
  372. return a
  373. },
  374. getDurationInUnit : function(d, a, c) {
  375. var b;
  376. switch (c) {
  377. case this.YEAR :
  378. b = Math.round(this.getDurationInYears(d, a));
  379. break;
  380. case this.QUARTER :
  381. b = Math.round(this.getDurationInMonths(d, a) / 3);
  382. break;
  383. case this.MONTH :
  384. b = Math.round(this.getDurationInMonths(d, a));
  385. break;
  386. case this.WEEK :
  387. b = Math.round(this.getDurationInDays(d, a)) / 7;
  388. break;
  389. case this.DAY :
  390. b = Math.round(this.getDurationInDays(d, a));
  391. break;
  392. case this.HOUR :
  393. b = Math.round(this.getDurationInHours(d, a));
  394. break;
  395. case this.MINUTE :
  396. b = Math.round(this.getDurationInMinutes(d, a));
  397. break;
  398. case this.SECOND :
  399. b = Math.round(this.getDurationInSeconds(d, a));
  400. break;
  401. case this.MILLI :
  402. b = Math.round(this.getDurationInMilliseconds(d, a));
  403. break
  404. }
  405. return b
  406. },
  407. getUnitToBaseUnitRatio : function(b, a) {
  408. if (b === a) {
  409. return 1
  410. }
  411. switch (b) {
  412. case this.YEAR :
  413. switch (a) {
  414. case this.QUARTER :
  415. return 1 / 4;
  416. case this.MONTH :
  417. return 1 / 12
  418. }
  419. break;
  420. case this.QUARTER :
  421. switch (a) {
  422. case this.YEAR :
  423. return 4;
  424. case this.MONTH :
  425. return 1 / 3
  426. }
  427. break;
  428. case this.MONTH :
  429. switch (a) {
  430. case this.YEAR :
  431. return 12;
  432. case this.QUARTER :
  433. return 3
  434. }
  435. break;
  436. case this.WEEK :
  437. switch (a) {
  438. case this.DAY :
  439. return 1 / 7;
  440. case this.HOUR :
  441. return 1 / 168
  442. }
  443. break;
  444. case this.DAY :
  445. switch (a) {
  446. case this.WEEK :
  447. return 7;
  448. case this.HOUR :
  449. return 1 / 24;
  450. case this.MINUTE :
  451. return 1 / 1440
  452. }
  453. break;
  454. case this.HOUR :
  455. switch (a) {
  456. case this.DAY :
  457. return 24;
  458. case this.MINUTE :
  459. return 1 / 60
  460. }
  461. break;
  462. case this.MINUTE :
  463. switch (a) {
  464. case this.HOUR :
  465. return 60;
  466. case this.SECOND :
  467. return 1 / 60;
  468. case this.MILLI :
  469. return 1 / 60000
  470. }
  471. break;
  472. case this.SECOND :
  473. switch (a) {
  474. case this.MILLI :
  475. return 1 / 1000
  476. }
  477. break;
  478. case this.MILLI :
  479. switch (a) {
  480. case this.SECOND :
  481. return 1000
  482. }
  483. break
  484. }
  485. return -1
  486. },
  487. getDurationInMilliseconds : function(b, a) {
  488. return (a - b)
  489. },
  490. getDurationInSeconds : function(b, a) {
  491. return (a - b) / 1000
  492. },
  493. getDurationInMinutes : function(b, a) {
  494. return (a - b) / 60000
  495. },
  496. getDurationInHours : function(b, a) {
  497. return (a - b) / 3600000
  498. },
  499. getDurationInDays : function(b, a) {
  500. return (a - b) / 86400000
  501. },
  502. getDurationInBusinessDays : function(g, b) {
  503. var c = Math.round((b - g) / 86400000), a = 0, f;
  504. for (var e = 0; e < c; e++) {
  505. f = this.add(g, this.DAY, e).getDay();
  506. if (f !== 6 && f !== 0) {
  507. a++
  508. }
  509. }
  510. return a
  511. },
  512. getDurationInMonths : function(b, a) {
  513. return ((a.getFullYear() - b.getFullYear()) * 12)
  514. + (a.getMonth() - b.getMonth())
  515. },
  516. getDurationInYears : function(b, a) {
  517. return this.getDurationInMonths(b, a) / 12
  518. },
  519. min : function(b, a) {
  520. return b < a ? b : a
  521. },
  522. max : function(b, a) {
  523. return b > a ? b : a
  524. },
  525. intersectSpans : function(c, d, b, a) {
  526. return this.betweenLesser(c, b, a)
  527. || this.betweenLesser(b, c, d)
  528. },
  529. getNameOfUnit : function(a) {
  530. a = this.getUnitByName(a);
  531. switch (a.toLowerCase()) {
  532. case this.YEAR :
  533. return "YEAR";
  534. case this.QUARTER :
  535. return "QUARTER";
  536. case this.MONTH :
  537. return "MONTH";
  538. case this.WEEK :
  539. return "WEEK";
  540. case this.DAY :
  541. return "DAY";
  542. case this.HOUR :
  543. return "HOUR";
  544. case this.MINUTE :
  545. return "MINUTE";
  546. case this.SECOND :
  547. return "SECOND";
  548. case this.MILLI :
  549. return "MILLI"
  550. }
  551. throw "Incorrect UnitName"
  552. },
  553. getReadableNameOfUnit : function(b, a) {
  554. return this.unitNames[b][a ? "plural" : "single"]
  555. },
  556. getShortNameOfUnit : function(a) {
  557. return this.unitNames[a].abbrev
  558. },
  559. getUnitByName : function(a) {
  560. if (!this.unitsByName[a]) {
  561. Ext.Error.raise("Unknown unit name: " + a)
  562. }
  563. return this.unitsByName[a]
  564. },
  565. getNext : function(c, g, a, f) {
  566. var e = Ext.Date.clone(c);
  567. f = arguments.length < 4 ? 1 : f;
  568. a = a || 1;
  569. switch (g) {
  570. case this.MILLI :
  571. e = this.add(c, g, a);
  572. break;
  573. case this.SECOND :
  574. e = this.add(c, g, a);
  575. e.setMilliseconds(0);
  576. break;
  577. case this.MINUTE :
  578. e = this.add(c, g, a);
  579. e.setSeconds(0);
  580. e.setMilliseconds(0);
  581. break;
  582. case this.HOUR :
  583. e = this.add(c, g, a);
  584. e.setMinutes(0);
  585. e.setSeconds(0);
  586. e.setMilliseconds(0);
  587. break;
  588. case this.DAY :
  589. var d = c.getHours() === 23
  590. && this.add(e, this.HOUR, 1).getHours() === 1;
  591. if (d) {
  592. e = this.add(e, this.DAY, 2);
  593. Ext.Date.clearTime(e);
  594. return e
  595. }
  596. Ext.Date.clearTime(e);
  597. e = this.add(e, this.DAY, a);
  598. break;
  599. case this.WEEK :
  600. Ext.Date.clearTime(e);
  601. var b = e.getDay();
  602. e = this.add(e, this.DAY, f - b + 7
  603. * (a - (f <= b ? 0 : 1)));
  604. if (e.getDay() !== f) {
  605. e = this.add(e, this.HOUR, 1)
  606. } else {
  607. Ext.Date.clearTime(e)
  608. }
  609. break;
  610. case this.MONTH :
  611. e = this.add(e, this.MONTH, a);
  612. e.setDate(1);
  613. Ext.Date.clearTime(e);
  614. break;
  615. case this.QUARTER :
  616. e = this.add(e, this.MONTH, ((a - 1) * 3)
  617. + (3 - (e.getMonth() % 3)));
  618. Ext.Date.clearTime(e);
  619. e.setDate(1);
  620. break;
  621. case this.YEAR :
  622. e = new Date(e.getFullYear() + a, 0, 1);
  623. break;
  624. default :
  625. throw "Invalid date unit"
  626. }
  627. return e
  628. },
  629. getNumberOfMsFromTheStartOfDay : function(a) {
  630. return a - Ext.Date.clearTime(a, true) || 86400000
  631. },
  632. getNumberOfMsTillTheEndOfDay : function(a) {
  633. return this.getStartOfNextDay(a, true) - a
  634. },
  635. getStartOfNextDay : function(b, e) {
  636. var d = this.add(Ext.Date.clearTime(b, e), this.DAY, 1);
  637. if (d.getDate() == b.getDate()) {
  638. var c = this.add(Ext.Date.clearTime(b, e), this.DAY, 2)
  639. .getTimezoneOffset();
  640. var a = b.getTimezoneOffset();
  641. d = this.add(d, this.MINUTE, a - c)
  642. }
  643. return d
  644. },
  645. getEndOfPreviousDay : function(b) {
  646. var a = Ext.Date.clearTime(b, true);
  647. if (a - b) {
  648. return a
  649. } else {
  650. return this.add(a, this.DAY, -1)
  651. }
  652. },
  653. timeSpanContains : function(c, b, d, a) {
  654. return (d - c) >= 0 && (b - a) >= 0
  655. }
  656. });
  657. Ext.define("Sch.util.DragTracker", {
  658. extend : "Ext.dd.DragTracker",
  659. xStep : 1,
  660. yStep : 1,
  661. setXStep : function(a) {
  662. this.xStep = a
  663. },
  664. setYStep : function(a) {
  665. this.yStep = a
  666. },
  667. getRegion : function() {
  668. var e = this.startXY, d = this.getXY(), b = Math.min(e[0], d[0]), f = Math
  669. .min(e[1], d[1]), c = Math.abs(e[0] - d[0]), a = Math.abs(e[1]
  670. - d[1]);
  671. return new Ext.util.Region(f, b + c, f + a, b)
  672. },
  673. onMouseDown : function(f, d) {
  674. if (this.disabled || f.dragTracked) {
  675. return
  676. }
  677. var c = f.getXY(), g, b, a = c[0], h = c[1];
  678. if (this.xStep > 1) {
  679. g = this.el.getX();
  680. a -= g;
  681. a = Math.round(a / this.xStep) * this.xStep;
  682. a += g
  683. }
  684. if (this.yStep > 1) {
  685. b = this.el.getY();
  686. h -= b;
  687. h = Math.round(h / this.yStep) * this.yStep;
  688. h += b
  689. }
  690. this.dragTarget = this.delegate ? d : this.handle.dom;
  691. this.startXY = this.lastXY = [a, h];
  692. this.startRegion = Ext.fly(this.dragTarget).getRegion();
  693. if (this.fireEvent("mousedown", this, f) === false
  694. || this.fireEvent("beforedragstart", this, f) === false
  695. || this.onBeforeStart(f) === false) {
  696. return
  697. }
  698. this.mouseIsDown = true;
  699. f.dragTracked = true;
  700. if (this.preventDefault !== false) {
  701. f.preventDefault()
  702. }
  703. Ext.getDoc().on({
  704. scope : this,
  705. mouseup : this.onMouseUp,
  706. mousemove : this.onMouseMove,
  707. selectstart : this.stopSelect
  708. });
  709. if (this.autoStart) {
  710. this.timer = Ext.defer(this.triggerStart, this.autoStart === true
  711. ? 1000
  712. : this.autoStart, this, [f])
  713. }
  714. },
  715. onMouseMove : function(g, f) {
  716. if (this.active && Ext.isIE && !g.browserEvent.button) {
  717. g.preventDefault();
  718. this.onMouseUp(g);
  719. return
  720. }
  721. g.preventDefault();
  722. var d = g.getXY(), b = this.startXY;
  723. if (!this.active) {
  724. if (Math.max(Math.abs(b[0] - d[0]), Math.abs(b[1] - d[1])) > this.tolerance) {
  725. this.triggerStart(g)
  726. } else {
  727. return
  728. }
  729. }
  730. var a = d[0], h = d[1];
  731. if (this.xStep > 1) {
  732. a -= this.startXY[0];
  733. a = Math.round(a / this.xStep) * this.xStep;
  734. a += this.startXY[0]
  735. }
  736. if (this.yStep > 1) {
  737. h -= this.startXY[1];
  738. h = Math.round(h / this.yStep) * this.yStep;
  739. h += this.startXY[1]
  740. }
  741. var c = this.xStep > 1 || this.yStep > 1;
  742. if (!c || a !== d[0] || h !== d[1]) {
  743. this.lastXY = [a, h];
  744. if (this.fireEvent("mousemove", this, g) === false) {
  745. this.onMouseUp(g)
  746. } else {
  747. this.onDrag(g);
  748. this.fireEvent("drag", this, g)
  749. }
  750. }
  751. }
  752. });
  753. Ext.define("Sch.util.HeaderRenderers", {
  754. singleton : true,
  755. requires : ["Sch.util.Date", "Ext.XTemplate"],
  756. constructor : function() {
  757. var b = Ext
  758. .create(
  759. "Ext.XTemplate",
  760. '<table class="sch-nested-hdr-tbl '
  761. + Ext.baseCSSPrefix
  762. + '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>')
  763. .compile();
  764. var a = Ext
  765. .create(
  766. "Ext.XTemplate",
  767. '<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>')
  768. .compile();
  769. return {
  770. quarterMinute : function(f, d, c, e) {
  771. c.headerCls = "sch-nested-hdr-pad";
  772. 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>'
  773. },
  774. dateCells : function(d, c, e) {
  775. return function(j, g, f) {
  776. f.headerCls = "sch-nested-hdr-nopad";
  777. var i = [], h = Ext.Date.clone(j);
  778. while (h < g) {
  779. i.push({
  780. text : Ext.Date.format(h, e)
  781. });
  782. h = Sch.util.Date.add(h, d, c)
  783. }
  784. i[0].cls = "sch-nested-hdr-cell-first";
  785. i[i.length - 1].cls = "sch-nested-hdr-cell-last";
  786. return a.apply(i)
  787. }
  788. },
  789. dateNumber : function(g, d, c) {
  790. c.headerCls = "sch-nested-hdr-nopad";
  791. var f = [], e = Ext.Date.clone(g);
  792. while (e < d) {
  793. f.push({
  794. dayOfWeek : e.getDay(),
  795. text : e.getDate()
  796. });
  797. e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1)
  798. }
  799. return b.apply(f)
  800. },
  801. dayLetter : function(g, d, c) {
  802. c.headerCls = "sch-nested-hdr-nopad";
  803. var f = [], e = g;
  804. while (e < d) {
  805. f.push({
  806. dayOfWeek : e.getDay(),
  807. text : Ext.Date.dayNames[e.getDay()].substr(0,
  808. 1)
  809. });
  810. e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1)
  811. }
  812. f[0].cls = "sch-nested-hdr-cell-first";
  813. f[f.length - 1].cls = "sch-nested-hdr-cell-last";
  814. return b.apply(f)
  815. },
  816. dayStartEndHours : function(e, d, c) {
  817. c.headerCls = "sch-hdr-startend";
  818. return Ext.String
  819. .format(
  820. '<span class="sch-hdr-start">{0}</span><span class="sch-hdr-end">{1}</span>',
  821. Ext.Date.format(e, "G"), Ext.Date
  822. .format(d, "G"))
  823. }
  824. }
  825. }
  826. });
  827. Ext.define("Sch.model.Customizable", {
  828. extend : "Ext.data.Model",
  829. customizableFields : null,
  830. onClassExtended : function(b, d, a) {
  831. var c = a.onBeforeCreated;
  832. a.onBeforeCreated = function(f, k) {
  833. c.call(this, f, k);
  834. var j = f.prototype;
  835. if (!j.customizableFields) {
  836. return
  837. }
  838. j.customizableFields = (f.superclass.customizableFields || [])
  839. .concat(j.customizableFields);
  840. var g = j.customizableFields;
  841. var i = {};
  842. Ext.Array.each(g, function(l) {
  843. if (typeof l == "string") {
  844. l = {
  845. name : l
  846. }
  847. }
  848. i[l.name] = l
  849. });
  850. var e = j.fields;
  851. var h = [];
  852. e.each(function(l) {
  853. if (l.isCustomizableField) {
  854. h.push(l)
  855. }
  856. });
  857. e.removeAll(h);
  858. Ext.Object.each(i, function(l, o) {
  859. o.isCustomizableField = true;
  860. var p = o.name;
  861. var t = p === "Id" ? "idProperty" : p.charAt(0).toLowerCase()
  862. + p.substr(1) + "Field";
  863. var q = j[t];
  864. var s = q || p;
  865. if (e.containsKey(s)) {
  866. e.getByKey(s).isCustomizableField = true;
  867. g.push(new Ext.data.Field(Ext.applyIf({
  868. name : p,
  869. isCustomizableField : true
  870. }, e.getByKey(s))))
  871. } else {
  872. e.add(new Ext.data.Field(Ext.applyIf({
  873. name : s,
  874. isCustomizableField : true
  875. }, o)))
  876. }
  877. var n = Ext.String.capitalize(p);
  878. if (n != "Id") {
  879. var r = "get" + n;
  880. var m = "set" + n;
  881. if (!j[r] || j[r].__getterFor__ && j[r].__getterFor__ != s) {
  882. j[r] = function() {
  883. return this.data[s]
  884. };
  885. j[r].__getterFor__ = s
  886. }
  887. if (!j[m] || j[m].__setterFor__ && j[m].__setterFor__ != s) {
  888. j[m] = function(u) {
  889. return this.set(s, u)
  890. };
  891. j[m].__setterFor__ = s
  892. }
  893. }
  894. })
  895. }
  896. },
  897. set : function(c, b) {
  898. if (arguments.length === 2) {
  899. this.previous = this.previous || {};
  900. var a = this.get(c);
  901. if (a !== b) {
  902. this.previous[c] = a
  903. }
  904. }
  905. this.callParent(arguments)
  906. },
  907. afterEdit : function() {
  908. this.callParent(arguments);
  909. delete this.previous
  910. },
  911. reject : function() {
  912. var b = this, a = b.modified, c;
  913. b.previous = b.previous || {};
  914. for (c in a) {
  915. if (a.hasOwnProperty(c)) {
  916. if (typeof a[c] != "function") {
  917. b.previous[c] = b.get(c)
  918. }
  919. }
  920. }
  921. b.callParent(arguments);
  922. delete b.previous
  923. }
  924. });
  925. Ext.define("Sch.patches.Model", {
  926. extend : "Sch.util.Patch",
  927. requires : "Sch.model.Customizable",
  928. reportURL : "http://www.sencha.com/forum/showthread.php?198250-4.1-Ext.data.Model-regression",
  929. description : "In Ext 4.1 Models cannot be subclassed",
  930. maxVersion : "4.1.0",
  931. applyFn : function() {
  932. try {
  933. Ext.define("Sch.foo", {
  934. extend : "Ext.data.Model",
  935. fields : ["a"]
  936. });
  937. Ext.define("Sch.foo.Sub", {
  938. extend : "Sch.foo",
  939. fields : ["a"]
  940. })
  941. } catch (a) {
  942. Ext.data.Types.AUTO.convert = function(b) {
  943. return b
  944. }
  945. }
  946. }
  947. });
  948. Ext.define("Sch.data.mixin.EventStore", {
  949. model : "Sch.model.Event",
  950. requires : ["Sch.util.Date"],
  951. isEventStore : true,
  952. setResourceStore : function(a) {
  953. if (this.resourceStore) {
  954. this.resourceStore.un({
  955. beforesync : this.onResourceStoreBeforeSync,
  956. write : this.onResourceStoreWrite,
  957. scope : this
  958. })
  959. }
  960. this.resourceStore = a;
  961. if (a) {
  962. a.on({
  963. beforesync : this.onResourceStoreBeforeSync,
  964. write : this.onResourceStoreWrite,
  965. scope : this
  966. })
  967. }
  968. },
  969. onResourceStoreBeforeSync : function(b, c) {
  970. var a = b.create;
  971. if (a) {
  972. for (var e, d = a.length - 1; d >= 0; d--) {
  973. e = a[d];
  974. e._phantomId = e.internalId
  975. }
  976. }
  977. },
  978. onResourceStoreWrite : function(c, b) {
  979. if (b.wasSuccessful()) {
  980. var d = this, a = b.getRecords();
  981. Ext.each(a, function(e) {
  982. if (e._phantomId && !e.phantom) {
  983. d.each(function(f) {
  984. if (f.getResourceId() === e._phantomId) {
  985. f.assign(e)
  986. }
  987. })
  988. }
  989. })
  990. }
  991. },
  992. isDateRangeAvailable : function(f, a, b, d) {
  993. var c = true, e = Sch.util.Date;
  994. this.each(function(g) {
  995. if (e
  996. .intersectSpans(f, a, g.getStartDate(), g
  997. .getEndDate())
  998. && d === g.getResource() && (!b || b !== g)) {
  999. c = false;
  1000. return false
  1001. }
  1002. });
  1003. return c
  1004. },
  1005. getEventsInTimeSpan : function(d, b, a) {
  1006. if (a !== false) {
  1007. var c = Sch.util.Date;
  1008. return this.queryBy(function(g) {
  1009. var f = g.getStartDate(), e = g.getEndDate();
  1010. return f && e && c.intersectSpans(f, e, d, b)
  1011. })
  1012. } else {
  1013. return this.queryBy(function(g) {
  1014. var f = g.getStartDate(), e = g.getEndDate();
  1015. return f && e && (f - d >= 0) && (b - e >= 0)
  1016. })
  1017. }
  1018. },
  1019. getTotalTimeSpan : function() {
  1020. var a = new Date(9999, 0, 1), b = new Date(0), c = Sch.util.Date;
  1021. this.each(function(d) {
  1022. if (d.getStartDate()) {
  1023. a = c.min(d.getStartDate(), a)
  1024. }
  1025. if (d.getEndDate()) {
  1026. b = c.max(d.getEndDate(), b)
  1027. }
  1028. });
  1029. a = a < new Date(9999, 0, 1) ? a : null;
  1030. b = b > new Date(0) ? b : null;
  1031. return {
  1032. start : a || null,
  1033. end : b || a || null
  1034. }
  1035. },
  1036. getEventsForResource : function(e) {
  1037. var c = [], d, f = e.getId() || e.internalId;
  1038. for (var b = 0, a = this.getCount(); b < a; b++) {
  1039. d = this.getAt(b);
  1040. if (d.data[d.resourceIdField] === f) {
  1041. c.push(d)
  1042. }
  1043. }
  1044. return c
  1045. },
  1046. getClosestSuccessor : function(g, e) {
  1047. var c = Infinity, a = g.getEnd(), f, h;
  1048. e = e || this.getRange();
  1049. for (var d = 0, b = e.length; d < b; d++) {
  1050. h = e[d].getStart() - a;
  1051. if (h >= 0 && h < c) {
  1052. f = e[d];
  1053. c = h
  1054. }
  1055. }
  1056. return f
  1057. }
  1058. });
  1059. Ext.define("Sch.model.Range", {
  1060. extend : "Sch.model.Customizable",
  1061. requires : ["Sch.util.Date", "Sch.patches.DataOperation"],
  1062. startDateField : "StartDate",
  1063. endDateField : "EndDate",
  1064. nameField : "Name",
  1065. clsField : "Cls",
  1066. customizableFields : [{
  1067. name : "StartDate",
  1068. type : "date",
  1069. dateFormat : "c"
  1070. }, {
  1071. name : "EndDate",
  1072. type : "date",
  1073. dateFormat : "c"
  1074. }, {
  1075. name : "Cls",
  1076. type : "string"
  1077. }, {
  1078. name : "Name",
  1079. type : "string"
  1080. }],
  1081. setStartDate : function(a, d) {
  1082. var c = this.getEndDate();
  1083. var b = this.getStartDate();
  1084. this.set(this.startDateField, a);
  1085. if (d === true && c && b) {
  1086. this.setEndDate(Sch.util.Date.add(a, Sch.util.Date.MILLI, c - b))
  1087. }
  1088. },
  1089. setEndDate : function(b, d) {
  1090. var a = this.getStartDate();
  1091. var c = this.getEndDate();
  1092. this.set(this.endDateField, b);
  1093. if (d === true && a && c) {
  1094. this.setStartDate(Sch.util.Date.add(b, Sch.util.Date.MILLI,
  1095. -(c - a)))
  1096. }
  1097. },
  1098. setStartEndDate : function(b, a) {
  1099. this.beginEdit();
  1100. this.set(this.startDateField, b);
  1101. this.set(this.endDateField, a);
  1102. this.endEdit()
  1103. },
  1104. getDates : function() {
  1105. var c = [], b = this.getEndDate();
  1106. for (var a = Ext.Date.clearTime(this.getStartDate(), true); a < b; a = Sch.util.Date
  1107. .add(a, Sch.util.Date.DAY, 1)) {
  1108. c.push(a)
  1109. }
  1110. return c
  1111. },
  1112. forEachDate : function(b, a) {
  1113. return Ext.each(this.getDates(), b, a)
  1114. },
  1115. isValid : function() {
  1116. var b = this.callParent(arguments);
  1117. if (b) {
  1118. var c = this.getStartDate(), a = this.getEndDate();
  1119. b = !c || !a || (a - c >= 0)
  1120. }
  1121. return b
  1122. },
  1123. shift : function(b, a) {
  1124. this.setStartEndDate(Sch.util.Date.add(this.getStartDate(), b, a),
  1125. Sch.util.Date.add(this.getEndDate(), b, a))
  1126. }
  1127. });
  1128. Ext.define("Sch.model.Resource", {
  1129. extend : "Sch.model.Customizable",
  1130. idProperty : "Id",
  1131. nameField : "Name",
  1132. customizableFields : ["Id", {
  1133. name : "Name",
  1134. type : "string"
  1135. }],
  1136. getEventStore : function() {
  1137. return this.stores[0] && this.stores[0].eventStore
  1138. || this.parentNode && this.parentNode.getEventStore()
  1139. },
  1140. getEvents : function(d) {
  1141. var c = [], e, f = this.getId() || this.internalId;
  1142. d = d || this.getEventStore();
  1143. for (var b = 0, a = d.getCount(); b < a; b++) {
  1144. e = d.getAt(b);
  1145. if (e.data[e.resourceIdField] === f) {
  1146. c.push(e)
  1147. }
  1148. }
  1149. return c
  1150. }
  1151. });
  1152. Ext.define("Sch.data.mixin.ResourceStore", {});
  1153. Ext.define("Sch.data.FilterableNodeStore", {
  1154. extend : "Ext.data.NodeStore",
  1155. onNodeExpand : function(f, d, c) {
  1156. var b = [];
  1157. for (var e = 0; e < d.length; e++) {
  1158. var a = d[e];
  1159. if (!(a.isHidden && a.isHidden() || a.hidden || a.data.hidden)) {
  1160. b[b.length] = a
  1161. }
  1162. }
  1163. return this.callParent([f, b, c])
  1164. }
  1165. });
  1166. Ext.define("Sch.data.mixin.FilterableTreeStore", {
  1167. requires : ["Sch.data.FilterableNodeStore"],
  1168. nodeStoreClassName : "Sch.data.FilterableNodeStore",
  1169. nodeStore : null,
  1170. isFilteredFlag : false,
  1171. initTreeFiltering : function() {
  1172. if (!this.nodeStore) {
  1173. this.nodeStore = this.createNodeStore(this)
  1174. }
  1175. this.addEvents("filter-set", "filter-clear",
  1176. "nodestore-datachange-start", "nodestore-datachange-end")
  1177. },
  1178. createNodeStore : function(a) {
  1179. return Ext.create(this.nodeStoreClassName, {
  1180. treeStore : a,
  1181. recursive : true,
  1182. rootVisible : this.rootVisible
  1183. })
  1184. },
  1185. clearTreeFilter : function() {
  1186. if (!this.isTreeFiltered()) {
  1187. return
  1188. }
  1189. this.refreshNodeStoreContent();
  1190. this.isFilteredFlag = false;
  1191. this.fireEvent("filter-clear", this)
  1192. },
  1193. refreshNodeStoreContent : function(f) {
  1194. var a = this.getRootNode(), d = [];
  1195. var c = this.rootVisible;
  1196. var b = function(i) {
  1197. if (i.isHidden && i.isHidden() || i.hidden || i.data.hidden) {
  1198. return
  1199. }
  1200. if (c || i != a) {
  1201. d[d.length] = i
  1202. }
  1203. if (!i.data.leaf && i.isExpanded()) {
  1204. var j = i.childNodes, h = j.length;
  1205. for (var g = 0; g < h; g++) {
  1206. b(j[g])
  1207. }
  1208. }
  1209. };
  1210. b(a);
  1211. this.fireEvent("nodestore-datachange-start", this);
  1212. var e = this.nodeStore;
  1213. if (!this.loadDataInNodeStore || !this.loadDataInNodeStore(d)) {
  1214. e.loadRecords(d)
  1215. }
  1216. if (!f) {
  1217. e.fireEvent("clear", e)
  1218. }
  1219. this.fireEvent("nodestore-datachange-end", this)
  1220. },
  1221. getIndexInTotalDataset : function(b) {
  1222. var a = this.getRootNode();
  1223. index = -1;
  1224. var d = this.rootVisible;
  1225. if (!d && b == a) {
  1226. return -1
  1227. }
  1228. var c = function(g) {
  1229. if (g.isHidden && g.isHidden() || g.hidden || g.data.hidden) {
  1230. if (g == b) {
  1231. return false
  1232. }
  1233. }
  1234. if (d || g != a) {
  1235. index++
  1236. }
  1237. if (g == b) {
  1238. return false
  1239. }
  1240. if (!g.data.leaf && g.isExpanded()) {
  1241. var h = g.childNodes, f = h.length;
  1242. for (var e = 0; e < f; e++) {
  1243. if (c(h[e]) === false) {
  1244. return false
  1245. }
  1246. }
  1247. }
  1248. };
  1249. c(a);
  1250. return index
  1251. },
  1252. isTreeFiltered : function() {
  1253. return this.isFilteredFlag
  1254. },
  1255. filterTreeBy : function(s, b) {
  1256. var g;
  1257. if (arguments.length == 1 && Ext.isObject(arguments[0])) {
  1258. b = s.scope;
  1259. g = s.filter
  1260. } else {
  1261. g = s;
  1262. s = {}
  1263. }
  1264. this.fireEvent("nodestore-datachange-start", this);
  1265. s = s || {};
  1266. var j = s.shallow;
  1267. var r = s.checkParents || j;
  1268. var h = s.fullMathchingParents;
  1269. var c = s.onlyParents || h;
  1270. var e = this.rootVisible;
  1271. if (c && r) {
  1272. throw new Error("Can't combine `onlyParents` and `checkParents` options")
  1273. }
  1274. var o = {};
  1275. var m = this.getRootNode(), d = [];
  1276. var a = function(t) {
  1277. var i = t.parentNode;
  1278. while (i && !o[i.internalId]) {
  1279. o[i.internalId] = true;
  1280. i = i.parentNode
  1281. }
  1282. };
  1283. var k = function(v) {
  1284. if (v.isHidden && v.isHidden() || v.hidden || v.data.hidden) {
  1285. return
  1286. }
  1287. var t, w, u, i;
  1288. if (v.data.leaf) {
  1289. if (g.call(b, v, o)) {
  1290. d[d.length] = v;
  1291. a(v)
  1292. }
  1293. } else {
  1294. if (e || v != m) {
  1295. d[d.length] = v
  1296. }
  1297. if (c) {
  1298. t = g.call(b, v);
  1299. w = v.childNodes;
  1300. u = w.length;
  1301. if (t) {
  1302. o[v.internalId] = true;
  1303. a(v);
  1304. if (h) {
  1305. v.cascadeBy(function(x) {
  1306. d[d.length] = x;
  1307. if (!x.data.leaf) {
  1308. o[x.internalId] = true
  1309. }
  1310. });
  1311. return
  1312. }
  1313. }
  1314. for (i = 0; i < u; i++) {
  1315. if (t && w[i].data.leaf) {
  1316. d[d.length] = w[i]
  1317. } else {
  1318. if (!w[i].data.leaf) {
  1319. k(w[i])
  1320. }
  1321. }
  1322. }
  1323. } else {
  1324. if (r) {
  1325. t = g.call(b, v, o);
  1326. if (t) {
  1327. o[v.internalId] = true;
  1328. a(v)
  1329. }
  1330. }
  1331. if (!r || !j || j && (t || v == m && !e)) {
  1332. w = v.childNodes;
  1333. u = w.length;
  1334. for (i = 0; i < u; i++) {
  1335. k(w[i])
  1336. }
  1337. }
  1338. }
  1339. }
  1340. };
  1341. k(m);
  1342. var f = [];
  1343. for (var p = 0, q = d.length; p < q; p++) {
  1344. var l = d[p];
  1345. if (l.data.leaf || o[l.internalId]) {
  1346. f[f.length] = l
  1347. }
  1348. }
  1349. var n = this.nodeStore;
  1350. if (!this.loadDataInNodeStore || !this.loadDataInNodeStore(f)) {
  1351. n.loadRecords(f, false);
  1352. n.fireEvent("clear", n)
  1353. }
  1354. this.isFilteredFlag = true;
  1355. this.fireEvent("nodestore-datachange-end", this);
  1356. this.fireEvent("filter-set", this)
  1357. },
  1358. hideNodesBy : function(b, a) {
  1359. if (this.isFiltered()) {
  1360. throw new Error("Can't hide nodes of the filtered tree store")
  1361. }
  1362. var c = this;
  1363. a = a || this;
  1364. this.getRootNode().cascadeBy(function(d) {
  1365. d.hidden = b.call(a, d, c)
  1366. });
  1367. this.refreshNodeStoreContent()
  1368. },
  1369. showAllNodes : function() {
  1370. this.getRootNode().cascadeBy(function(a) {
  1371. a.hidden = a.data.hidden = false
  1372. });
  1373. this.refreshNodeStoreContent()
  1374. }
  1375. });
  1376. Ext.define("Sch.data.mixin.BufferableTreeStore", {
  1377. viewSize : 50,
  1378. buffered : false,
  1379. rangeStart : null,
  1380. rangeEnd : null,
  1381. initTreeBuffering : function() {
  1382. if (!this.buffered) {
  1383. return
  1384. }
  1385. var b = this;
  1386. var a = {
  1387. append : this.updateBufferedNodeStore,
  1388. insert : this.updateBufferedNodeStore,
  1389. remove : this.updateBufferedNodeStore,
  1390. move : this.updateBufferedNodeStore,
  1391. expand : this.updateBufferedNodeStore,
  1392. collapse : this.updateBufferedNodeStore,
  1393. sort : this.updateBufferedNodeStore,
  1394. scope : this,
  1395. buffer : 1
  1396. };
  1397. this.on(a);
  1398. this.on("root-fill-start", function() {
  1399. b.nodeStore.suspendEvents();
  1400. b.un(a);
  1401. b.nodeStore.setNode()
  1402. });
  1403. this.on("root-fill-end", function() {
  1404. b.nodeStore.resumeEvents();
  1405. b.on(a);
  1406. this.updateBufferedNodeStore()
  1407. })
  1408. },
  1409. updateBufferedNodeStore : function() {
  1410. this.refreshNodeStoreContent(true)
  1411. },
  1412. loadDataInNodeStore : function(a) {
  1413. if (!this.buffered) {
  1414. return false
  1415. }
  1416. var b = this.nodeStore;
  1417. b.totalCount = a.length;
  1418. if (!a.length) {
  1419. b.removeAll()
  1420. }
  1421. b.cachePage(a, 1);
  1422. this.guaranteeRange(this.rangeStart || 0, this.rangeEnd
  1423. || this.viewSize || 50);
  1424. return true
  1425. },
  1426. guaranteeRange : function(e, d) {
  1427. var b = this.viewSize || 50;
  1428. var f = this.nodeStore;
  1429. var a = f.getTotalCount();
  1430. if (a) {
  1431. var c = d - e + 1;
  1432. if (c < b && a >= c) {
  1433. d = e + b - 1
  1434. }
  1435. if (d >= a) {
  1436. e = a - (d - e);
  1437. d = a - 1;
  1438. e = Math.max(0, e)
  1439. }
  1440. f.guaranteeRange(e, d)
  1441. }
  1442. },
  1443. createNodeStore : function(a) {
  1444. var b = Ext.create(this.nodeStoreClassName
  1445. || "Ext.data.NodeStore", {
  1446. treeStore : a,
  1447. recursive : true,
  1448. rootVisible : this.rootVisible,
  1449. buffered : a.buffered,
  1450. purgePageCount : 0,
  1451. pageSize : 10000000000
  1452. });
  1453. if (a.buffered) {
  1454. this.mon(b, "guaranteedrange", function(d, e, c) {
  1455. this.rangeStart = e;
  1456. this.rangeEnd = c
  1457. }, this)
  1458. }
  1459. return b
  1460. }
  1461. });
  1462. Ext.define("Sch.data.ResourceStore", {
  1463. extend : "Ext.data.Store",
  1464. model : "Sch.model.Resource",
  1465. mixins : ["Sch.data.mixin.ResourceStore"]
  1466. });
  1467. Ext.define("Sch.data.TimeAxis", {
  1468. extend : "Ext.util.Observable",
  1469. requires : ["Ext.data.JsonStore", "Sch.util.Date"],
  1470. continuous : true,
  1471. autoAdjust : true,
  1472. constructor : function(a) {
  1473. Ext.apply(this, a);
  1474. this.originalContinuous = this.continuous;
  1475. this.addEvents("beforereconfigure", "reconfigure");
  1476. this.tickStore = new Ext.data.JsonStore({
  1477. fields : ["start", "end"]
  1478. });
  1479. this.tickStore.on("datachanged", function() {
  1480. this.fireEvent("reconfigure", this)
  1481. }, this);
  1482. this.callParent(arguments)
  1483. },
  1484. reconfigure : function(a) {
  1485. Ext.apply(this, a);
  1486. var c = this.tickStore, b = this.generateTicks(this.start, this.end,
  1487. this.unit, this.increment || 1, this.mainUnit);
  1488. if (this.fireEvent("beforereconfigure", this, this.start, this.end) !== false) {
  1489. c.suspendEvents(true);
  1490. c.loadData(b);
  1491. if (c.getCount() === 0) {
  1492. Ext.Error
  1493. .raise("Invalid time axis configuration or filter, please check your input data.")
  1494. }
  1495. c.resumeEvents()
  1496. }
  1497. },
  1498. setTimeSpan : function(b, a) {
  1499. this.reconfigure({
  1500. start : b,
  1501. end : a
  1502. })
  1503. },
  1504. filterBy : function(b, a) {
  1505. this.continuous = false;
  1506. a = a || this;
  1507. var c = this.tickStore;
  1508. c.clearFilter(true);
  1509. c.suspendEvents(true);
  1510. c.filter([{
  1511. filterFn : function(e, d) {
  1512. return b.call(a, e.data, d)
  1513. }
  1514. }]);
  1515. if (c.getCount() === 0) {
  1516. Ext.Error
  1517. .raise("Invalid time axis filter - no columns passed through the filter. Please check your filter method.");
  1518. this.clearFilter()
  1519. }
  1520. c.resumeEvents()
  1521. },
  1522. isContinuous : function() {
  1523. return this.continuous && !this.tickStore.isFiltered()
  1524. },
  1525. clearFilter : function() {
  1526. this.continuous = this.originalContinuous;
  1527. this.tickStore.clearFilter()
  1528. },
  1529. generateTicks : function(a, d, g, i) {
  1530. var h = [], f, b = Sch.util.Date, e = 0;
  1531. g = g || this.unit;
  1532. i = i || this.increment;
  1533. if (this.autoAdjust) {
  1534. a = this.floorDate(a || this.getStart(), false);
  1535. d = this.ceilDate(d || b.add(a, this.mainUnit, this.defaultSpan),
  1536. false)
  1537. }
  1538. while (a < d) {
  1539. f = this.getNext(a, g, i);
  1540. if (g === b.HOUR && i > 1 && h.length > 0 && e === 0) {
  1541. var c = h[h.length - 1];
  1542. e = ((c.start.getHours() + i) % 24) - c.end.getHours();
  1543. if (e !== 0) {
  1544. f = b.add(f, b.HOUR, e)
  1545. }
  1546. }
  1547. h.push({
  1548. start : a,
  1549. end : f
  1550. });
  1551. a = f
  1552. }
  1553. return h
  1554. },
  1555. getTickFromDate : function(c) {
  1556. if (this.getStart() > c || this.getEnd() < c) {
  1557. return -1
  1558. }
  1559. var f = this.tickStore.getRange(), e, a, d, b;
  1560. for (d = 0, b = f.length; d < b; d++) {
  1561. a = f[d].data.end;
  1562. if (c <= a) {
  1563. e = f[d].data.start;
  1564. return d + (c > e ? (c - e) / (a - e) : 0)
  1565. }
  1566. }
  1567. return -1
  1568. },
  1569. getDateFromTick : function(d, f) {
  1570. var g = this.tickStore.getCount();
  1571. if (d === g) {
  1572. return this.getEnd()
  1573. }
  1574. var a = Math.floor(d), e = d - a, c = this.getAt(a);
  1575. var b = Sch.util.Date.add(c.start, Sch.util.Date.MILLI, e
  1576. * (c.end - c.start));
  1577. if (f) {
  1578. b = this[f + "Date"](b)
  1579. }
  1580. return b
  1581. },
  1582. getAt : function(a) {
  1583. return this.tickStore.getAt(a).data
  1584. },
  1585. getCount : function() {
  1586. return this.tickStore.getCount()
  1587. },
  1588. getTicks : function() {
  1589. var a = [];
  1590. this.tickStore.each(function(b) {
  1591. a.push(b.data)
  1592. });
  1593. return a
  1594. },
  1595. getStart : function() {
  1596. var a = this.tickStore.first();
  1597. if (a) {
  1598. return Ext.Date.clone(a.data.start)
  1599. }
  1600. return null
  1601. },
  1602. getEnd : function() {
  1603. var a = this.tickStore.last();
  1604. if (a) {
  1605. return Ext.Date.clone(a.data.end)
  1606. }
  1607. return null
  1608. },
  1609. roundDate : function(r) {
  1610. var l = Ext.Date.clone(r), b = this.getStart(), s = this.resolutionIncrement;
  1611. switch (this.resolutionUnit) {
  1612. case Sch.util.Date.MILLI :
  1613. var e = Sch.util.Date.getDurationInMilliseconds(b, l), d = Math
  1614. .round(e / s)
  1615. * s;
  1616. l = Sch.util.Date.add(b, Sch.util.Date.MILLI, d);
  1617. break;
  1618. case Sch.util.Date.SECOND :
  1619. var i = Sch.util.Date.getDurationInSeconds(b, l), q = Math
  1620. .round(i / s)
  1621. * s;
  1622. l = Sch.util.Date.add(b, Sch.util.Date.MILLI, q * 1000);
  1623. break;
  1624. case Sch.util.Date.MINUTE :
  1625. var n = Sch.util.Date.getDurationInMinutes(b, l), a = Math
  1626. .round(n / s)
  1627. * s;
  1628. l = Sch.util.Date.add(b, Sch.util.Date.SECOND, a * 60);
  1629. break;
  1630. case Sch.util.Date.HOUR :
  1631. var m = Sch.util.Date.getDurationInHours(this.getStart(), l), j = Math
  1632. .round(m / s)
  1633. * s;
  1634. l = Sch.util.Date.add(b, Sch.util.Date.MINUTE, j * 60);
  1635. break;
  1636. case Sch.util.Date.DAY :
  1637. var c = Sch.util.Date.getDurationInDays(b, l), f = Math.round(c
  1638. / s)
  1639. * s;
  1640. l = Sch.util.Date.add(b, Sch.util.Date.DAY, f);
  1641. break;
  1642. case Sch.util.Date.WEEK :
  1643. Ext.Date.clearTime(l);
  1644. var o = l.getDay() - this.weekStartDay, t;
  1645. if (o < 0) {
  1646. o = 7 + o
  1647. }
  1648. if (Math.round(o / 7) === 1) {
  1649. t = 7 - o
  1650. } else {
  1651. t = -o
  1652. }
  1653. l = Sch.util.Date.add(l, Sch.util.Date.DAY, t);
  1654. break;
  1655. case Sch.util.Date.MONTH :
  1656. var p = Sch.util.Date.getDurationInMonths(b, l)
  1657. + (l.getDate() / Ext.Date.getDaysInMonth(l)), h = Math
  1658. .round(p / s)
  1659. * s;
  1660. l = Sch.util.Date.add(b, Sch.util.Date.MONTH, h);
  1661. break;
  1662. case Sch.util.Date.QUARTER :
  1663. Ext.Date.clearTime(l);
  1664. l.setDate(1);
  1665. l = Sch.util.Date.add(l, Sch.util.Date.MONTH, 3
  1666. - (l.getMonth() % 3));
  1667. break;
  1668. case Sch.util.Date.YEAR :
  1669. var k = Sch.util.Date.getDurationInYears(b, l), g = Math
  1670. .round(k / s)
  1671. * s;
  1672. l = Sch.util.Date.add(b, Sch.util.Date.YEAR, g);
  1673. break
  1674. }
  1675. return l
  1676. },
  1677. floorDate : function(t, d, v) {
  1678. d = d !== false;
  1679. var n = Ext.Date.clone(t), b = d ? this.getStart() : null, u = this.resolutionIncrement, k;
  1680. if (v) {
  1681. k = v
  1682. } else {
  1683. k = d ? this.resolutionUnit : this.mainUnit
  1684. }
  1685. switch (k) {
  1686. case Sch.util.Date.MILLI :
  1687. if (d) {
  1688. var f = Sch.util.Date.getDurationInMilliseconds(b, n), e = Math
  1689. .floor(f / u)
  1690. * u;
  1691. n = Sch.util.Date.add(b, Sch.util.Date.MILLI, e)
  1692. }
  1693. break;
  1694. case Sch.util.Date.SECOND :
  1695. if (d) {
  1696. var j = Sch.util.Date.getDurationInSeconds(b, n), s = Math
  1697. .floor(j / u)
  1698. * u;
  1699. n = Sch.util.Date.add(b, Sch.util.Date.MILLI, s * 1000)
  1700. } else {
  1701. n.setMilliseconds(0)
  1702. }
  1703. break;
  1704. case Sch.util.Date.MINUTE :
  1705. if (d) {
  1706. var p = Sch.util.Date.getDurationInMinutes(b, n), a = Math
  1707. .floor(p / u)
  1708. * u;
  1709. n = Sch.util.Date.add(b, Sch.util.Date.SECOND, a * 60)
  1710. } else {
  1711. n.setSeconds(0);
  1712. n.setMilliseconds(0)
  1713. }
  1714. break;
  1715. case Sch.util.Date.HOUR :
  1716. if (d) {
  1717. var o = Sch.util.Date
  1718. .getDurationInHours(this.getStart(), n), l = Math
  1719. .floor(o / u)
  1720. * u;
  1721. n = Sch.util.Date.add(b, Sch.util.Date.MINUTE, l * 60)
  1722. } else {
  1723. n.setMinutes(0);
  1724. n.setSeconds(0);
  1725. n.setMilliseconds(0)
  1726. }
  1727. break;
  1728. case Sch.util.Date.DAY :
  1729. if (d) {
  1730. var c = Sch.util.Date.getDurationInDays(b, n), g = Math
  1731. .floor(c / u)
  1732. * u;
  1733. n = Sch.util.Date.add(b, Sch.util.Date.DAY, g)
  1734. } else {
  1735. Ext.Date.clearTime(n)
  1736. }
  1737. break;
  1738. case Sch.util.Date.WEEK :
  1739. var r = n.getDay();
  1740. Ext.Date.clearTime(n);
  1741. if (r !== this.weekStartDay) {
  1742. n = Sch.util.Date.add(n, Sch.util.Date.DAY,
  1743. -(r > this.weekStartDay
  1744. ? (r - this.weekStartDay)
  1745. : (7 - r - this.weekStartDay)))
  1746. }
  1747. break;
  1748. case Sch.util.Date.MONTH :
  1749. if (d) {
  1750. var q = Sch.util.Date.getDurationInMonths(b, n), i = Math
  1751. .floor(q / u)
  1752. * u;
  1753. n = Sch.util.Date.add(b, Sch.util.Date.MONTH, i)
  1754. } else {
  1755. Ext.Date.clearTime(n);
  1756. n.setDate(1)
  1757. }
  1758. break;
  1759. case Sch.util.Date.QUARTER :
  1760. Ext.Date.clearTime(n);
  1761. n.setDate(1);
  1762. n = Sch.util.Date.add(n, Sch.util.Date.MONTH,
  1763. -(n.getMonth() % 3));
  1764. break;
  1765. case Sch.util.Date.YEAR :
  1766. if (d) {
  1767. var m = Sch.util.Date.getDurationInYears(b, n), h = Math
  1768. .floor(m / u)
  1769. * u;
  1770. n = Sch.util.Date.add(b, Sch.util.Date.YEAR, h)
  1771. } else {
  1772. n = new Date(t.getFullYear(), 0, 1)
  1773. }
  1774. break
  1775. }
  1776. return n
  1777. },
  1778. ceilDate : function(c, b, f) {
  1779. var e = Ext.Date.clone(c);
  1780. b = b !== false;
  1781. var a = b ? this.resolutionIncrement : 1, g = false, d;
  1782. if (f) {
  1783. d = f
  1784. } else {
  1785. d = b ? this.resolutionUnit : this.mainUnit
  1786. }
  1787. switch (d) {
  1788. case Sch.util.Date.DAY :
  1789. if (e.getMinutes() > 0 || e.getSeconds() > 0
  1790. || e.getMilliseconds() > 0) {
  1791. g = true
  1792. }
  1793. break;
  1794. case Sch.util.Date.WEEK :
  1795. Ext.Date.clearTime(e);
  1796. if (e.getDay() !== this.weekStartDay) {
  1797. g = true
  1798. }
  1799. break;
  1800. case Sch.util.Date.MONTH :
  1801. Ext.Date.clearTime(e);
  1802. if (e.getDate() !== 1) {
  1803. g = true
  1804. }
  1805. break;
  1806. case Sch.util.Date.QUARTER :
  1807. Ext.Date.clearTime(e);
  1808. if (e.getMonth() % 3 !== 0) {
  1809. g = true
  1810. }
  1811. break;
  1812. case Sch.util.Date.YEAR :
  1813. Ext.Date.clearTime(e);
  1814. if (e.getMonth() !== 0 && e.getDate() !== 1) {
  1815. g = true
  1816. }
  1817. break;
  1818. default :
  1819. break
  1820. }
  1821. if (g) {
  1822. return this.getNext(e, d, a)
  1823. } else {
  1824. return e
  1825. }
  1826. },
  1827. getNext : function(b, c, a) {
  1828. return Sch.util.Date.getNext(b, c, a, this.weekStartDay)
  1829. },
  1830. getResolution : function() {
  1831. return {
  1832. unit : this.resolutionUnit,
  1833. increment : this.resolutionIncrement
  1834. }
  1835. },
  1836. setResolution : function(b, a) {
  1837. this.resolutionUnit = b;
  1838. this.resolutionIncrement = a || 1
  1839. },
  1840. shiftNext : function(a) {
  1841. a = a || this.getShiftIncrement();
  1842. var b = this.getShiftUnit();
  1843. this.setTimeSpan(Sch.util.Date.add(this.getStart(), b, a),
  1844. Sch.util.Date.add(this.getEnd(), b, a))
  1845. },
  1846. shiftPrevious : function(a) {
  1847. a = -(a || this.getShiftIncrement());
  1848. var b = this.getShiftUnit();
  1849. this.setTimeSpan(Sch.util.Date.add(this.getStart(), b, a),
  1850. Sch.util.Date.add(this.getEnd(), b, a))
  1851. },
  1852. getShiftUnit : function() {
  1853. return this.shiftUnit || this.getMainUnit()
  1854. },
  1855. getShiftIncrement : function() {
  1856. return this.shiftIncrement || 1
  1857. },
  1858. getUnit : function() {
  1859. return this.unit
  1860. },
  1861. getIncrement : function() {
  1862. return this.increment
  1863. },
  1864. timeSpanInAxis : function(b, a) {
  1865. if (this.continuous) {
  1866. return Sch.util.Date.intersectSpans(b, a, this.getStart(), this
  1867. .getEnd())
  1868. } else {
  1869. return (b < this.getStart() && a > this.getEnd())
  1870. || this.getTickFromDate(b) !== this.getTickFromDate(a)
  1871. }
  1872. },
  1873. forEachInterval : function(b, a, c) {
  1874. c = c || this;
  1875. if (b === "top" || (b === "middle" && this.headerConfig.bottom)) {
  1876. this.forEachAuxInterval(b, a, c)
  1877. } else {
  1878. this.tickStore.each(function(e, d) {
  1879. return a.call(c, e.data.start, e.data.end, d)
  1880. })
  1881. }
  1882. },
  1883. forEachMainInterval : function(a, b) {
  1884. this.forEachInterval("middle", a, b)
  1885. },
  1886. forEachAuxInterval : function(b, a, f) {
  1887. f = f || this;
  1888. var c = this.getEnd(), g = this.getStart(), e = 0, d;
  1889. while (g < c) {
  1890. d = Sch.util.Date.min(this.getNext(g, this.headerConfig[b].unit,
  1891. this.headerConfig[b].increment || 1), c);
  1892. a.call(f, g, d, e);
  1893. g = d;
  1894. e++
  1895. }
  1896. }
  1897. });
  1898. Ext.define("Sch.preset.Manager", {
  1899. extend : "Ext.util.MixedCollection",
  1900. requires : ["Sch.util.Date", "Sch.util.HeaderRenderers"],
  1901. singleton : true,
  1902. constructor : function() {
  1903. this.callParent(arguments);
  1904. this.registerDefaults()
  1905. },
  1906. registerPreset : function(b, a) {
  1907. if (a) {
  1908. var c = a.headerConfig;
  1909. var d = Sch.util.Date;
  1910. for (var e in c) {
  1911. if (c.hasOwnProperty(e)) {
  1912. if (d[c[e].unit]) {
  1913. c[e].unit = d[c[e].unit.toUpperCase()]
  1914. }
  1915. }
  1916. }
  1917. if (!a.timeColumnWidth) {
  1918. a.timeColumnWidth = 50
  1919. }
  1920. if (a.timeResolution && d[a.timeResolution.unit]) {
  1921. a.timeResolution.unit = d[a.timeResolution.unit
  1922. .toUpperCase()]
  1923. }
  1924. if (a.shiftUnit && d[a.shiftUnit]) {
  1925. a.shiftUnit = d[a.shiftUnit.toUpperCase()]
  1926. }
  1927. }
  1928. if (this.isValidPreset(a)) {
  1929. if (this.containsKey(b)) {
  1930. this.removeAtKey(b)
  1931. }
  1932. this.add(b, a)
  1933. } else {
  1934. throw "Invalid preset, please check your configuration"
  1935. }
  1936. },
  1937. isValidPreset : function(a) {
  1938. var d = Sch.util.Date, b = true, c = Sch.util.Date.units;
  1939. for (var e in a.headerConfig) {
  1940. if (a.headerConfig.hasOwnProperty(e)) {
  1941. b = b
  1942. && Ext.Array.indexOf(c, a.headerConfig[e].unit) >= 0
  1943. }
  1944. }
  1945. if (a.timeResolution) {
  1946. b = b && Ext.Array.indexOf(c, a.timeResolution.unit) >= 0
  1947. }
  1948. if (a.shiftUnit) {
  1949. b = b && Ext.Array.indexOf(c, a.shiftUnit) >= 0
  1950. }
  1951. return b
  1952. },
  1953. getPreset : function(a) {
  1954. return this.get(a)
  1955. },
  1956. deletePreset : function(a) {
  1957. this.removeAtKey(a)
  1958. },
  1959. registerDefaults : function() {
  1960. var b = this, a = this.defaultPresets;
  1961. for (var c in a) {
  1962. b.registerPreset(c, a[c])
  1963. }
  1964. },
  1965. defaultPresets : {
  1966. minuteAndHour : {
  1967. timeColumnWidth : 100,
  1968. rowHeight : 24,
  1969. resourceColumnWidth : 100,
  1970. displayDateFormat : "G:i",
  1971. shiftIncrement : 1,
  1972. shiftUnit : "HOUR",
  1973. defaultSpan : 24,
  1974. timeResolution : {
  1975. unit : "MINUTE",
  1976. increment : 30
  1977. },
  1978. headerConfig : {
  1979. middle : {
  1980. unit : "MINUTE",
  1981. increment : "30",
  1982. dateFormat : "i"
  1983. },
  1984. top : {
  1985. unit : "HOUR",
  1986. dateFormat : "D, GA/m"
  1987. }
  1988. }
  1989. },
  1990. hourAndDay : {
  1991. timeColumnWidth : 60,
  1992. rowHeight : 24,
  1993. resourceColumnWidth : 100,
  1994. displayDateFormat : "G:i",
  1995. shiftIncrement : 1,
  1996. shiftUnit : "DAY",
  1997. defaultSpan : 24,
  1998. timeResolution : {
  1999. unit : "MINUTE",
  2000. increment : 30
  2001. },
  2002. headerConfig : {
  2003. middle : {
  2004. unit : "HOUR",
  2005. dateFormat : "G:i"
  2006. },
  2007. top : {
  2008. unit : "DAY",
  2009. dateFormat : "D d/m"
  2010. }
  2011. }
  2012. },
  2013. dayAndWeek : {
  2014. timeColumnWidth : 100,
  2015. rowHeight : 24,
  2016. resourceColumnWidth : 100,
  2017. displayDateFormat : "Y-m-d G:i",
  2018. shiftUnit : "DAY",
  2019. shiftIncrement : 1,
  2020. defaultSpan : 5,
  2021. timeResolution : {
  2022. unit : "HOUR",
  2023. increment : 1
  2024. },
  2025. headerConfig : {
  2026. middle : {
  2027. unit : "DAY",
  2028. dateFormat : "D d M"
  2029. },
  2030. top : {
  2031. unit : "WEEK",
  2032. dateFormat : "W M Y",
  2033. renderer : function(c, b, a) {
  2034. return Sch.util.Date.getShortNameOfUnit("WEEK")
  2035. + "." + Ext.Date.format(c, "W M Y")
  2036. }
  2037. }
  2038. }
  2039. },
  2040. weekAndDay : {
  2041. timeColumnWidth : 100,
  2042. rowHeight : 24,
  2043. resourceColumnWidth : 100,
  2044. displayDateFormat : "Y-m-d",
  2045. shiftUnit : "WEEK",
  2046. shiftIncrement : 1,
  2047. defaultSpan : 1,
  2048. timeResolution : {
  2049. unit : "DAY",
  2050. increment : 1
  2051. },
  2052. headerConfig : {
  2053. bottom : {
  2054. unit : "DAY",
  2055. increment : 1,
  2056. dateFormat : "d/m"
  2057. },
  2058. middle : {
  2059. unit : "WEEK",
  2060. dateFormat : "D d M",
  2061. align : "left"
  2062. }
  2063. }
  2064. },
  2065. weekAndMonth : {
  2066. timeColumnWidth : 100,
  2067. rowHeight : 24,
  2068. resourceColumnWidth : 100,
  2069. displayDateFormat : "Y-m-d",
  2070. shiftUnit : "WEEK",
  2071. shiftIncrement : 5,
  2072. defaultSpan : 6,
  2073. timeResolution : {
  2074. unit : "DAY",
  2075. increment : 1
  2076. },
  2077. headerConfig : {
  2078. middle : {
  2079. unit : "WEEK",
  2080. renderer : function(c, b, a) {
  2081. a.align = "left";
  2082. return Ext.Date.format(c, "d M")
  2083. }
  2084. },
  2085. top : {
  2086. unit : "MONTH",
  2087. dateFormat : "M Y"
  2088. }
  2089. }
  2090. },
  2091. monthAndYear : {
  2092. timeColumnWidth : 110,
  2093. rowHeight : 24,
  2094. resourceColumnWidth : 100,
  2095. displayDateFormat : "Y-m-d",
  2096. shiftIncrement : 3,
  2097. shiftUnit : "MONTH",
  2098. defaultSpan : 12,
  2099. timeResolution : {
  2100. unit : "DAY",
  2101. increment : 1
  2102. },
  2103. headerConfig : {
  2104. middle : {
  2105. unit : "MONTH",
  2106. dateFormat : "M Y"
  2107. },
  2108. top : {
  2109. unit : "YEAR",
  2110. dateFormat : "Y"
  2111. }
  2112. }
  2113. },
  2114. year : {
  2115. timeColumnWidth : 100,
  2116. rowHeight : 24,
  2117. resourceColumnWidth : 100,
  2118. displayDateFormat : "Y-m-d",
  2119. shiftUnit : "YEAR",
  2120. shiftIncrement : 1,
  2121. defaultSpan : 1,
  2122. timeResolution : {
  2123. unit : "MONTH",
  2124. increment : 1
  2125. },
  2126. headerConfig : {
  2127. bottom : {
  2128. unit : "QUARTER",
  2129. renderer : function(c, b, a) {
  2130. return Ext.String.format(Sch.util.Date
  2131. .getShortNameOfUnit("QUARTER")
  2132. .toUpperCase()
  2133. + "{0}", Math.floor(c
  2134. .getMonth()
  2135. / 3)
  2136. + 1)
  2137. }
  2138. },
  2139. middle : {
  2140. unit : "YEAR",
  2141. dateFormat : "Y"
  2142. }
  2143. }
  2144. },
  2145. weekAndDayLetter : {
  2146. timeColumnWidth : 20,
  2147. rowHeight : 24,
  2148. resourceColumnWidth : 100,
  2149. displayDateFormat : "Y-m-d",
  2150. shiftUnit : "WEEK",
  2151. shiftIncrement : 1,
  2152. defaultSpan : 10,
  2153. timeResolution : {
  2154. unit : "DAY",
  2155. increment : 1
  2156. },
  2157. headerConfig : {
  2158. bottom : {
  2159. unit : "DAY",
  2160. increment : 1,
  2161. renderer : function(a) {
  2162. return Ext.Date.dayNames[a.getDay()].substring(
  2163. 0, 1)
  2164. }
  2165. },
  2166. middle : {
  2167. unit : "WEEK",
  2168. dateFormat : "D d M Y",
  2169. align : "left"
  2170. }
  2171. }
  2172. },
  2173. weekDateAndMonth : {
  2174. timeColumnWidth : 30,
  2175. rowHeight : 24,
  2176. resourceColumnWidth : 100,
  2177. displayDateFormat : "Y-m-d",
  2178. shiftUnit : "WEEK",
  2179. shiftIncrement : 1,
  2180. defaultSpan : 10,
  2181. timeResolution : {
  2182. unit : "DAY",
  2183. increment : 1
  2184. },
  2185. headerConfig : {
  2186. middle : {
  2187. unit : "WEEK",
  2188. dateFormat : "d"
  2189. },
  2190. top : {
  2191. unit : "MONTH",
  2192. dateFormat : "Y F",
  2193. align : "left"
  2194. }
  2195. }
  2196. }
  2197. }
  2198. });
  2199. Ext.define("Sch.feature.AbstractTimeSpan", {
  2200. extend : "Ext.AbstractPlugin",
  2201. lockableScope : "normal",
  2202. schedulerView : null,
  2203. timeAxis : null,
  2204. containerEl : null,
  2205. expandToFitView : false,
  2206. disabled : false,
  2207. cls : null,
  2208. template : null,
  2209. store : null,
  2210. renderElementsBuffered : false,
  2211. renderDelay : 15,
  2212. constructor : function(a) {
  2213. this.uniqueCls = this.uniqueCls || ("sch-timespangroup-" + Ext.id());
  2214. Ext.apply(this, a)
  2215. },
  2216. setDisabled : function(a) {
  2217. if (a) {
  2218. this.removeElements()
  2219. }
  2220. this.disabled = a
  2221. },
  2222. getElements : function() {
  2223. if (this.containerEl) {
  2224. return this.containerEl.select("." + this.uniqueCls)
  2225. }
  2226. return null
  2227. },
  2228. removeElements : function() {
  2229. var a = this.getElements();
  2230. if (a) {
  2231. a.remove()
  2232. }
  2233. },
  2234. init : function(a) {
  2235. this.timeAxis = a.getTimeAxis();
  2236. this.schedulerView = a.getSchedulingView();
  2237. if (!this.store) {
  2238. Ext.Error.raise("Error: You must define a store for this plugin")
  2239. }
  2240. this.schedulerView.on({
  2241. afterrender : this.onAfterRender,
  2242. destroy : this.onDestroy,
  2243. scope : this
  2244. })
  2245. },
  2246. onAfterRender : function(b) {
  2247. var a = this.schedulerView;
  2248. this.containerEl = a.el;
  2249. a.mon(this.store, {
  2250. load : this.renderElements,
  2251. datachanged : this.renderElements,
  2252. clear : this.renderElements,
  2253. add : this.renderElements,
  2254. remove : this.renderElements,
  2255. update : this.refreshSingle,
  2256. scope : this
  2257. });
  2258. if (Ext.data.NodeStore && a.store instanceof Ext.data.NodeStore) {
  2259. if (a.animate) {
  2260. } else {
  2261. a.mon(a.store, {
  2262. expand : this.renderElements,
  2263. collapse : this.renderElements,
  2264. scope : this
  2265. })
  2266. }
  2267. }
  2268. a.on({
  2269. refresh : this.renderElements,
  2270. itemadd : this.renderElements,
  2271. itemremove : this.renderElements,
  2272. itemupdate : this.renderElements,
  2273. groupexpand : this.renderElements,
  2274. groupcollapse : this.renderElements,
  2275. columnwidthchange : this.renderElements,
  2276. resize : this.renderElements,
  2277. scope : this
  2278. });
  2279. a.headerCt.on({
  2280. add : this.renderElements,
  2281. remove : this.renderElements,
  2282. scope : this
  2283. });
  2284. a.ownerCt.up("panel").on({
  2285. viewchange : this.renderElements,
  2286. orientationchange : this.renderElements,
  2287. scope : this
  2288. });
  2289. this.renderElements()
  2290. },
  2291. renderElements : function() {
  2292. if (this.renderElementsBuffered || this.disabled
  2293. || this.schedulerView.headerCt.getColumnCount() === 0) {
  2294. return
  2295. }
  2296. this.renderElementsBuffered = true;
  2297. Ext.Function.defer(this.renderElementsInternal, this.renderDelay, this)
  2298. },
  2299. renderElementsInternal : function() {
  2300. this.renderElementsBuffered = false;
  2301. if (this.disabled || this.schedulerView.isDestroyed
  2302. || this.schedulerView.headerCt.getColumnCount() === 0) {
  2303. return
  2304. }
  2305. this.removeElements();
  2306. Ext.core.DomHelper.insertHtml("afterBegin", this.containerEl.dom, this
  2307. .generateMarkup())
  2308. },
  2309. generateMarkup : function(b) {
  2310. var d = this.timeAxis.getStart(), a = this.timeAxis.getEnd(), c = this
  2311. .getElementData(d, a, null, b);
  2312. return this.template.apply(c)
  2313. },
  2314. getElementData : function(b, a) {
  2315. throw "Abstract method call"
  2316. },
  2317. onDestroy : function() {
  2318. if (this.store.autoDestroy) {
  2319. this.store.destroy()
  2320. }
  2321. },
  2322. refreshSingle : function(c, b) {
  2323. var e = Ext.get(this.uniqueCls + "-" + b.internalId);
  2324. if (e) {
  2325. var g = this.timeAxis.getStart(), a = this.timeAxis.getEnd(), f = this
  2326. .getElementData(g, a, [b])[0], d = b.clsField || "Cls";
  2327. if (f) {
  2328. e.dom.className = this.cls + " " + this.uniqueCls + " "
  2329. + (f[d] || "");
  2330. e.setTop(f.top);
  2331. e.setLeft(f.left);
  2332. e.setSize(f.width, f.height)
  2333. } else {
  2334. Ext.destroy(e)
  2335. }
  2336. } else {
  2337. this.renderElements()
  2338. }
  2339. }
  2340. });
  2341. Ext.define("Sch.plugin.Lines", {
  2342. extend : "Sch.feature.AbstractTimeSpan",
  2343. cls : "sch-timeline",
  2344. showTip : true,
  2345. innerTpl : null,
  2346. init : function(b) {
  2347. this.callParent(arguments);
  2348. var a = this.schedulerView;
  2349. if (Ext.isString(this.innerTpl)) {
  2350. this.innerTpl = new Ext.XTemplate(this.innerTpl)
  2351. }
  2352. var c = this.innerTpl;
  2353. if (!this.template) {
  2354. this.template = new Ext.XTemplate(
  2355. '<tpl for=".">',
  2356. '<div id="'
  2357. + this.uniqueCls
  2358. + '-{id}"'
  2359. + (this.showTip
  2360. ? 'title="{[this.getTipText(values)]}" '
  2361. : "")
  2362. + 'class="'
  2363. + this.cls
  2364. + " "
  2365. + this.uniqueCls
  2366. + ' {Cls}" style="left:{left}px;top:{top}px;height:{height}px;width:{width}px">'
  2367. + (c ? "{[this.renderInner(values)]}" : "")
  2368. + "</div>", "</tpl>", {
  2369. getTipText : function(d) {
  2370. return a.getFormattedDate(d.Date) + " "
  2371. + (d.Text || "")
  2372. },
  2373. renderInner : function(d) {
  2374. return c.apply(d)
  2375. }
  2376. })
  2377. }
  2378. },
  2379. getElementData : function(j, m, c) {
  2380. var n = this.store, h = this.schedulerView, e = c || n.getRange(), g = [], a, b, k;
  2381. for (var f = 0, d = e.length; f < d; f++) {
  2382. a = e[f];
  2383. b = a.get("Date");
  2384. if (b && Sch.util.Date.betweenLesser(b, j, m)) {
  2385. k = h.getTimeSpanRegion(b, null, this.expandToFitView);
  2386. g[g.length] = Ext.apply({
  2387. id : a.internalId,
  2388. left : k.left,
  2389. top : k.top,
  2390. width : 1,
  2391. height : k.bottom - k.top
  2392. }, a.data)
  2393. }
  2394. }
  2395. return g
  2396. }
  2397. });
  2398. Ext.define("Sch.plugin.Zones", {
  2399. extend : "Sch.feature.AbstractTimeSpan",
  2400. innerTpl : null,
  2401. requires : ["Sch.model.Range"],
  2402. cls : "sch-zone",
  2403. init : function(a) {
  2404. if (Ext.isString(this.innerTpl)) {
  2405. this.innerTpl = new Ext.XTemplate(this.innerTpl)
  2406. }
  2407. var b = this.innerTpl;
  2408. if (!this.template) {
  2409. this.template = new Ext.XTemplate(
  2410. '<tpl for="."><div id="'
  2411. + this.uniqueCls
  2412. + '-{id}" class="'
  2413. + this.cls
  2414. + " "
  2415. + this.uniqueCls
  2416. + ' {Cls}" style="left:{left}px;top:{top}px;height:{height}px;width:{width}px;{style}">'
  2417. + (b ? "{[this.renderInner(values)]}" : "")
  2418. + "</div></tpl>", {
  2419. renderInner : function(c) {
  2420. return b.apply(c)
  2421. }
  2422. })
  2423. }
  2424. this.callParent(arguments)
  2425. },
  2426. getElementData : function(k, o, d, p) {
  2427. var q = this.store, j = this.schedulerView, f = d || q.getRange(), h = [], a, n, c, m;
  2428. for (var g = 0, e = f.length; g < e; g++) {
  2429. a = f[g];
  2430. n = a.getStartDate();
  2431. c = a.getEndDate();
  2432. if (n && c && Sch.util.Date.intersectSpans(n, c, k, o)) {
  2433. m = j.getTimeSpanRegion(Sch.util.Date.max(n, k), Sch.util.Date
  2434. .min(c, o), this.expandToFitView);
  2435. var b = m.right - m.left;
  2436. h[h.length] = Ext.apply({
  2437. id : a.internalId,
  2438. left : m.left,
  2439. top : m.top,
  2440. width : p ? 0 : b,
  2441. height : m.bottom - m.top,
  2442. style : p ? ("border-left-width:" + b + "px") : "",
  2443. Cls : a.getCls()
  2444. }, a.data)
  2445. }
  2446. }
  2447. return h
  2448. }
  2449. });
  2450. Ext.define("Sch.plugin.Pan", {
  2451. alias : "plugin.pan",
  2452. extend : "Ext.AbstractPlugin",
  2453. lockableScope : "normal",
  2454. enableVerticalPan : true,
  2455. panel : null,
  2456. constructor : function(a) {
  2457. Ext.apply(this, a)
  2458. },
  2459. init : function(a) {
  2460. this.panel = a.normalGrid || a;
  2461. this.view = a.getSchedulingView();
  2462. this.view.on("afterrender", this.onRender, this)
  2463. },
  2464. onRender : function(a) {
  2465. this.view.el.on("mousedown", this.onMouseDown, this)
  2466. },
  2467. onMouseDown : function(b, a) {
  2468. if (b.getTarget("." + this.view.timeCellCls, 10)
  2469. && !b.getTarget(this.view.eventSelector)) {
  2470. this.mouseX = b.getPageX();
  2471. this.mouseY = b.getPageY();
  2472. Ext.getBody().on("mousemove", this.onMouseMove, this);
  2473. Ext.getDoc().on("mouseup", this.onMouseUp, this);
  2474. if (Ext.isIE || Ext.isGecko) {
  2475. Ext.getBody().on("mouseenter", this.onMouseUp, this)
  2476. }
  2477. b.stopEvent()
  2478. }
  2479. },
  2480. onMouseMove : function(d) {
  2481. d.stopEvent();
  2482. var a = d.getPageX(), f = d.getPageY(), c = a - this.mouseX, b = f
  2483. - this.mouseY;
  2484. this.panel.scrollByDeltaX(-c);
  2485. this.mouseX = a;
  2486. this.mouseY = f;
  2487. if (this.enableVerticalPan) {
  2488. this.panel.scrollByDeltaY(-b)
  2489. }
  2490. },
  2491. onMouseUp : function(a) {
  2492. Ext.getBody().un("mousemove", this.onMouseMove, this);
  2493. Ext.getDoc().un("mouseup", this.onMouseUp, this);
  2494. if (Ext.isIE || Ext.isGecko) {
  2495. Ext.getBody().un("mouseenter", this.onMouseUp, this)
  2496. }
  2497. }
  2498. });
  2499. Ext.define("Sch.view.Locking", {
  2500. extend : "Ext.grid.LockingView",
  2501. scheduleEventRelayRe : /^(schedule|event|beforeevent|afterevent|dragcreate|beforedragcreate|afterdragcreate|beforetooltipshow)/,
  2502. constructor : function(b) {
  2503. this.callParent(arguments);
  2504. var e = this, g = [], a = e.scheduleEventRelayRe, f = b.normal
  2505. .getView(), c = f.events, d;
  2506. for (d in c) {
  2507. if (c.hasOwnProperty(d) && a.test(d)) {
  2508. g.push(d)
  2509. }
  2510. }
  2511. e.relayEvents(f, g)
  2512. },
  2513. getElementFromEventRecord : function(a) {
  2514. return this.normal.getView().getElementFromEventRecord(a)
  2515. },
  2516. onClear : function() {
  2517. this.relayFn("onClear", arguments)
  2518. },
  2519. beginBulkUpdate : function() {
  2520. this.relayFn("beginBulkUpdate", arguments)
  2521. },
  2522. endBulkUpdate : function() {
  2523. this.relayFn("endBulkUpdate", arguments)
  2524. },
  2525. refreshKeepingScroll : function() {
  2526. this.locked.getView().refresh();
  2527. this.normal.getView().refreshKeepingScroll()
  2528. }
  2529. });
  2530. Ext.define("Sch.column.Time", {
  2531. extend : "Ext.grid.column.Column",
  2532. alias : "timecolumn",
  2533. draggable : false,
  2534. groupable : false,
  2535. hideable : false,
  2536. sortable : false,
  2537. fixed : true,
  2538. align : "center",
  2539. tdCls : "sch-timetd",
  2540. menuDisabled : true,
  2541. initComponent : function() {
  2542. this.addEvents("timeheaderdblclick");
  2543. this.enableBubble("timeheaderdblclick");
  2544. this.callParent()
  2545. },
  2546. initRenderData : function() {
  2547. var a = this;
  2548. a.renderData.headerCls = a.renderData.headerCls || a.headerCls;
  2549. return a.callParent(arguments)
  2550. },
  2551. onElDblClick : function(b, a) {
  2552. this.callParent(arguments);
  2553. this.fireEvent("timeheaderdblclick", this, this.startDate,
  2554. this.endDate, b)
  2555. }
  2556. }, function() {
  2557. Sch.column.Time.prototype.renderTpl = Sch.column.Time.prototype.renderTpl
  2558. .replace("column-header-inner",
  2559. "column-header-inner sch-timeheader {headerCls}")
  2560. });
  2561. Ext.define("Sch.column.timeAxis.Horizontal", {
  2562. extend : "Ext.grid.column.Column",
  2563. alias : "widget.timeaxiscolumn",
  2564. requires : ["Ext.Date", "Ext.XTemplate", "Sch.column.Time",
  2565. "Sch.preset.Manager"],
  2566. cls : "sch-timeaxiscolumn",
  2567. timeAxis : null,
  2568. renderTpl : '<div id="{id}-titleEl" class="'
  2569. + Ext.baseCSSPrefix
  2570. + 'column-header-inner"><span id="{id}-textEl" style="display:none" class="'
  2571. + Ext.baseCSSPrefix
  2572. + 'column-header-text"></span><tpl if="topHeaderCells">{topHeaderCells}</tpl><tpl if="middleHeaderCells">{middleHeaderCells}</tpl></div>{%this.renderContainer(out,values)%}',
  2573. headerRowTpl : '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}" class="sch-header-row sch-header-row-{position}"><thead><tr>{cells}</tr></thead></table>',
  2574. 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>',
  2575. columnConfig : {},
  2576. timeCellRenderer : null,
  2577. timeCellRendererScope : null,
  2578. columnWidth : null,
  2579. previousWidth : null,
  2580. previousHeight : null,
  2581. initComponent : function() {
  2582. if (!(this.headerRowTpl instanceof Ext.Template)) {
  2583. this.headerRowTpl = Ext.create("Ext.XTemplate", this.headerRowTpl)
  2584. }
  2585. if (!(this.headerCellTpl instanceof Ext.Template)) {
  2586. this.headerCellTpl = Ext
  2587. .create("Ext.XTemplate", this.headerCellTpl)
  2588. }
  2589. this.columns = [{}];
  2590. this.addEvents("timeheaderdblclick", "timeaxiscolumnreconfigured");
  2591. this.enableBubble("timeheaderdblclick");
  2592. this.stubForResizer = new Ext.Component({
  2593. isOnLeftEdge : function() {
  2594. return false
  2595. },
  2596. isOnRightEdge : function() {
  2597. return false
  2598. },
  2599. el : {
  2600. dom : {
  2601. style : {}
  2602. }
  2603. }
  2604. });
  2605. this.callParent(arguments);
  2606. this.onTimeAxisReconfigure();
  2607. this
  2608. .mon(this.timeAxis, "reconfigure", this.onTimeAxisReconfigure,
  2609. this)
  2610. },
  2611. getSchedulingView : function() {
  2612. return this.getOwnerHeaderCt().view
  2613. },
  2614. onTimeAxisReconfigure : function() {
  2615. var e = this.timeAxis, d = e.preset.timeColumnWidth, f = this.rendered
  2616. && this.getSchedulingView(), g = e.headerConfig, b = e
  2617. .getStart(), c = e.getEnd(), h = {
  2618. renderer : this.timeColumnRenderer,
  2619. scope : this,
  2620. width : this.rendered ? f.calculateTimeColumnWidth(d) : d
  2621. };
  2622. delete this.previousWidth;
  2623. delete this.previousHeight;
  2624. var j = this.columnConfig = this.createColumns(this.timeAxis, g, h);
  2625. Ext.suspendLayouts();
  2626. this.removeAll();
  2627. if (this.rendered) {
  2628. var a = this.el.child(".x-column-header-inner");
  2629. a.select("table").remove();
  2630. var i = this.initRenderData();
  2631. if (j.top) {
  2632. Ext.core.DomHelper.append(a, i.topHeaderCells)
  2633. }
  2634. if (j.middle) {
  2635. Ext.core.DomHelper.append(a, i.middleHeaderCells)
  2636. }
  2637. if (!j.top && !j.middle) {
  2638. this.addCls("sch-header-single-row")
  2639. } else {
  2640. this.removeCls("sch-header-single-row")
  2641. }
  2642. }
  2643. Ext.resumeLayouts();
  2644. this.add(j.bottom);
  2645. if (this.rendered) {
  2646. if (this.fireEvent("timeaxiscolumnreconfigured", this) !== false) {
  2647. f.refresh()
  2648. }
  2649. }
  2650. },
  2651. beforeRender : function() {
  2652. var a = this.columnConfig;
  2653. if (!a.middle && !a.top) {
  2654. this.addCls("sch-header-single-row")
  2655. }
  2656. this.callParent(arguments)
  2657. },
  2658. timeColumnRenderer : function(i, e, f, l, d, c, k) {
  2659. var a = "";
  2660. if (Ext.isIE) {
  2661. e.style += ";z-index:" + (this.items.getCount() - d)
  2662. }
  2663. if (this.timeCellRenderer) {
  2664. var h = this.timeAxis, b = h.getAt(d), g = b.start, j = b.end;
  2665. a = this.timeCellRenderer.call(this.timeCellRendererScope || this,
  2666. e, f, l, d, c, g, j)
  2667. }
  2668. return a
  2669. },
  2670. initRenderData : function() {
  2671. var a = this.columnConfig;
  2672. var c = a.top ? this.headerRowTpl.apply({
  2673. cells : this.headerCellTpl.apply(a.top),
  2674. position : "top",
  2675. tstyle : "border-top : 0; width : 100px"
  2676. }) : "";
  2677. var b = a.middle ? this.headerRowTpl.apply({
  2678. cells : this.headerCellTpl.apply(a.middle),
  2679. position : "middle",
  2680. tstyle : a.top
  2681. ? "width : 100px"
  2682. : "border-top : 0; width : 100px"
  2683. }) : "";
  2684. return Ext.apply(this.callParent(arguments), {
  2685. topHeaderCells : c,
  2686. middleHeaderCells : b
  2687. })
  2688. },
  2689. defaultRenderer : function(c, b, a) {
  2690. return Ext.Date.format(c, a)
  2691. },
  2692. createColumns : function(f, d, g) {
  2693. if (!f || !d) {
  2694. throw "Invalid parameters passed to createColumns"
  2695. }
  2696. var c = [], a = d.bottom || d.middle, h, e = this;
  2697. f.forEachInterval(d.bottom ? "bottom" : "middle", function(l, j, k) {
  2698. h = {
  2699. align : a.align || "center",
  2700. headerCls : "",
  2701. startDate : l,
  2702. endDate : j
  2703. };
  2704. if (a.renderer) {
  2705. h.header = a.renderer.call(a.scope || e, l, j, h, k)
  2706. } else {
  2707. h.header = e.defaultRenderer(l, j, a.dateFormat)
  2708. }
  2709. c[c.length] = Ext
  2710. .create("Sch.column.Time", Ext.apply(h, g))
  2711. });
  2712. var b = this.createHeaderRows(f, d);
  2713. return {
  2714. bottom : c,
  2715. middle : b.middle,
  2716. top : b.top
  2717. }
  2718. },
  2719. createHeaderRows : function(e, c) {
  2720. var d = {};
  2721. if (c.top) {
  2722. var a;
  2723. if (c.top.cellGenerator) {
  2724. a = c.top.cellGenerator.call(this, e.getStart(), e.getEnd())
  2725. } else {
  2726. a = this.createHeaderRow(e, c.top)
  2727. }
  2728. d.top = this.processHeaderRow(a, "top")
  2729. }
  2730. if (c.bottom) {
  2731. var b;
  2732. if (c.middle.cellGenerator) {
  2733. b = c.middle.cellGenerator.call(this, e.getStart(), e.getEnd())
  2734. } else {
  2735. b = this.createHeaderRow(e, c.middle)
  2736. }
  2737. d.middle = this.processHeaderRow(b, "middle")
  2738. }
  2739. return d
  2740. },
  2741. processHeaderRow : function(c, a) {
  2742. var b = this;
  2743. Ext.each(c, function(d, e) {
  2744. d.index = e;
  2745. d.position = a;
  2746. d.headerId = b.stubForResizer.id
  2747. });
  2748. return c
  2749. },
  2750. createHeaderRow : function(e, k) {
  2751. var n = [], l, a = e.getStart(), c = e.getEnd(), m = c - a, j = [], b = a, d = 0, f, g = k.align
  2752. || "center", h;
  2753. while (b < c) {
  2754. h = Sch.util.Date.min(e.getNext(b, k.unit, k.increment || 1), c);
  2755. l = {
  2756. align : g,
  2757. start : b,
  2758. end : h,
  2759. headerCls : ""
  2760. };
  2761. if (k.renderer) {
  2762. l.header = k.renderer.call(k.scope || this, b, h, l, d)
  2763. } else {
  2764. l.header = this.defaultRenderer(b, h, k.dateFormat, l, d)
  2765. }
  2766. n.push(l);
  2767. b = h;
  2768. d++
  2769. }
  2770. return n
  2771. },
  2772. afterLayout : function() {
  2773. delete this.columnWidth;
  2774. this.callParent(arguments);
  2775. var b = this.getWidth();
  2776. var g = this.getHeight();
  2777. if (b === this.previousWidth && g === this.previousHeight) {
  2778. return
  2779. }
  2780. this.previousWidth = b;
  2781. this.previousHeight = g;
  2782. var i = this.columnConfig;
  2783. var e = this;
  2784. var c = this.el;
  2785. var f = i.top;
  2786. var d = 0;
  2787. var a = 0;
  2788. if (f) {
  2789. c.select(".sch-header-row-top").setWidth(this.lastBox.width);
  2790. c.select(".sch-header-row-top td").each(function(l, m, j) {
  2791. var k = e.getHeaderGroupCellWidth(f[j].start, f[j].end);
  2792. l.setVisibilityMode(Ext.Element.DISPLAY);
  2793. if (k) {
  2794. d += k;
  2795. l.show();
  2796. l.setWidth(k)
  2797. } else {
  2798. l.hide()
  2799. }
  2800. })
  2801. }
  2802. var h = i.middle;
  2803. if (h) {
  2804. c.select(".sch-header-row-middle").setWidth(this.lastBox.width);
  2805. c.select(".sch-header-row-middle td").each(function(l, m, j) {
  2806. var k = e.getHeaderGroupCellWidth(h[j].start, h[j].end);
  2807. l.setVisibilityMode(Ext.Element.DISPLAY);
  2808. if (k) {
  2809. a += k;
  2810. l.show();
  2811. l.setWidth(k)
  2812. } else {
  2813. l.hide()
  2814. }
  2815. })
  2816. }
  2817. },
  2818. getHeaderGroupCellWidth : function(h, b) {
  2819. var e = this.timeAxis.unit, d = this.timeAxis.increment, c, g = Sch.util.Date
  2820. .getMeasuringUnit(e), a = Sch.util.Date.getDurationInUnit(h, b,
  2821. g), f = this.getSchedulingView();
  2822. if (this.timeAxis.isContinuous()) {
  2823. c = a * f.getSingleUnitInPixels(g)
  2824. } else {
  2825. c = f.getXYFromDate(b)[0] - f.getXYFromDate(h)[0]
  2826. }
  2827. return c
  2828. },
  2829. onElDblClick : function(d, f) {
  2830. this.callParent(arguments);
  2831. var e = d.getTarget(".sch-column-header");
  2832. if (e) {
  2833. var a = Ext.fly(e).getAttribute("headerPosition"), b = Ext.fly(e)
  2834. .getAttribute("headerIndex"), c = this.columnConfig[a][b];
  2835. this.fireEvent("timeheaderdblclick", this, c.start, c.end, d)
  2836. }
  2837. },
  2838. getTimeColumnWidth : function() {
  2839. if (this.columnWidth === null) {
  2840. this.columnWidth = this.items.get(0).getWidth()
  2841. }
  2842. return this.columnWidth
  2843. },
  2844. setTimeColumnWidth : function(a) {
  2845. this.suspendEvents();
  2846. this.items.each(function(b) {
  2847. b.setWidth(a)
  2848. });
  2849. this.resumeEvents()
  2850. }
  2851. });
  2852. Ext.define("Sch.column.timeAxis.HorizontalSingle", {
  2853. extend : "Sch.column.Time",
  2854. alias : "widget.singletimeaxiscolumn",
  2855. requires : ["Ext.Date", "Ext.XTemplate", "Sch.preset.Manager"],
  2856. cls : "sch-simple-timeaxis",
  2857. timeAxis : null,
  2858. trackHeaderOver : true,
  2859. compactCellWidthThreshold : 16,
  2860. renderTpl : '<div id="{id}-titleEl" class="'
  2861. + Ext.baseCSSPrefix
  2862. + 'column-header-inner"><span id="{id}-textEl" style="display:none" class="'
  2863. + Ext.baseCSSPrefix
  2864. + 'column-header-text"></span><tpl if="topHeaderCells">{topHeaderCells}</tpl><tpl if="middleHeaderCells">{middleHeaderCells}</tpl><tpl if="bottomHeaderCells">{bottomHeaderCells}</tpl></div>{%this.renderContainer(out,values)%}',
  2865. 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>',
  2866. columnConfig : {},
  2867. columnWidth : null,
  2868. nbrTimeColumns : null,
  2869. initComponent : function() {
  2870. this.tdCls += " sch-singletimetd";
  2871. if (!(this.headerRowTpl instanceof Ext.Template)) {
  2872. this.headerRowTpl = Ext.create("Ext.XTemplate", this.headerRowTpl)
  2873. }
  2874. this.addEvents("timeheaderdblclick", "timeaxiscolumnreconfigured");
  2875. this.enableBubble("timeheaderdblclick");
  2876. this.callParent(arguments);
  2877. this.onTimeAxisReconfigure();
  2878. this
  2879. .mon(this.timeAxis, "reconfigure", this.onTimeAxisReconfigure,
  2880. this);
  2881. this.on("resize", this.refreshHeaderSizes, this);
  2882. this.ownHoverCls = this.hoverCls;
  2883. this.hoverCls = ""
  2884. },
  2885. getSchedulingView : function() {
  2886. return this.getOwnerHeaderCt().view
  2887. },
  2888. onTimeAxisReconfigure : function() {
  2889. var h = this.timeAxis, g = h.preset.timeColumnWidth, j = this.rendered
  2890. && this.getSchedulingView(), l = h.headerConfig, c = h
  2891. .getStart(), f = h.getEnd(), d = this.rendered ? j
  2892. .calculateTimeColumnWidth(g) : g;
  2893. var o = this.columnConfig = this.createHeaderRows(l);
  2894. var a = o.bottom || o.middle;
  2895. if (this.rendered) {
  2896. var e;
  2897. var b = this.el.child(".x-column-header-inner");
  2898. var i = b.dom;
  2899. var k = i.style.display;
  2900. var m = i.parentNode;
  2901. i.style.display = "none";
  2902. m.removeChild(i);
  2903. i.innerHTML = "";
  2904. var n = this.initRenderData();
  2905. if (o.top) {
  2906. e = Ext.core.DomHelper.append(b, n.topHeaderCells);
  2907. this.refreshHeaderRow("top", e)
  2908. }
  2909. if (o.middle) {
  2910. e = Ext.core.DomHelper.append(b, n.middleHeaderCells);
  2911. this.refreshHeaderRow("middle", e)
  2912. }
  2913. if (o.bottom) {
  2914. e = Ext.core.DomHelper.append(b, n.bottomHeaderCells);
  2915. this.refreshHeaderRow("bottom", e)
  2916. }
  2917. if (!o.top && !o.middle) {
  2918. this.addCls("sch-header-single-row")
  2919. } else {
  2920. this.removeCls("sch-header-single-row")
  2921. }
  2922. m.appendChild(i);
  2923. i.style.display = k;
  2924. if (d !== this.columnWidth || this.nbrTimeColumns !== a.length) {
  2925. this.nbrTimeColumns = a.length;
  2926. this.setTimeColumnWidth(d)
  2927. }
  2928. if (this.fireEvent("timeaxiscolumnreconfigured", this) !== false) {
  2929. j.refreshKeepingResourceScroll(true)
  2930. }
  2931. } else {
  2932. if (d !== this.columnWidth || this.nbrTimeColumns !== a.length) {
  2933. this.nbrTimeColumns = a.length;
  2934. this.setTimeColumnWidth(d)
  2935. }
  2936. }
  2937. },
  2938. beforeRender : function() {
  2939. var b = this, a = this.columnConfig;
  2940. if (!a.middle && !a.top) {
  2941. b.addCls("sch-header-single-row")
  2942. }
  2943. b.callParent(arguments)
  2944. },
  2945. afterRender : function() {
  2946. var a = this;
  2947. if (this.trackHeaderOver) {
  2948. a.el.on({
  2949. mousemove : a.highlightCell,
  2950. delegate : "div.sch-simple-timeheader",
  2951. scope : a
  2952. });
  2953. a.el.on({
  2954. mouseleave : a.clearHighlight,
  2955. scope : a
  2956. })
  2957. }
  2958. a.callParent(arguments)
  2959. },
  2960. initRenderData : function() {
  2961. var a = this.columnConfig;
  2962. var c = a.top ? this.headerRowTpl.apply({
  2963. cells : a.top,
  2964. position : "top",
  2965. tstyle : "border-top : 0; width : 100px"
  2966. }) : "";
  2967. var b = a.middle ? this.headerRowTpl.apply({
  2968. cells : a.middle,
  2969. position : "middle",
  2970. tstyle : a.top
  2971. ? "width : 100px"
  2972. : "border-top : 0; width : 100px"
  2973. }) : "";
  2974. var d = a.bottom ? this.headerRowTpl.apply({
  2975. cells : a.bottom,
  2976. position : "bottom",
  2977. tstyle : "width : 100px"
  2978. }) : "";
  2979. return Ext.apply(this.callParent(arguments), {
  2980. topHeaderCells : c,
  2981. middleHeaderCells : b,
  2982. bottomHeaderCells : d
  2983. })
  2984. },
  2985. defaultRenderer : function(c, b, a) {
  2986. return Ext.Date.format(c, a)
  2987. },
  2988. createHeaderRows : function(a) {
  2989. var b = {};
  2990. for (var c in a) {
  2991. if (a[c].cellGenerator) {
  2992. b[c] = a[c].cellGenerator.call(this, this.timeAxis.getStart(),
  2993. this.timeAxis.getEnd())
  2994. } else {
  2995. b[c] = this.createHeaderRow(c, a[c])
  2996. }
  2997. }
  2998. return b
  2999. },
  3000. createHeaderRow : function(a, c) {
  3001. var b = [], d = this, f, e = c.align || "center";
  3002. this.timeAxis.forEachInterval(a, function(j, g, h) {
  3003. f = {
  3004. align : e,
  3005. start : j,
  3006. end : g,
  3007. headerCls : ""
  3008. };
  3009. if (c.renderer) {
  3010. f.header = c.renderer.call(c.scope || d, j, g, f, h)
  3011. } else {
  3012. f.header = d.defaultRenderer(j, g, c.dateFormat, f, h)
  3013. }
  3014. if (c.unit === Sch.util.Date.DAY
  3015. && (!c.increment || c.increment === 1)) {
  3016. f.headerCls += " sch-dayheadercell-" + j.getDay()
  3017. }
  3018. b.push(f)
  3019. });
  3020. return b
  3021. },
  3022. afterLayout : function() {
  3023. this.callParent(arguments);
  3024. this.refreshHeaderSizes()
  3025. },
  3026. refreshHeaderSizes : function() {
  3027. var a = this.columnConfig;
  3028. if (a.top) {
  3029. this.refreshHeaderRow("top")
  3030. }
  3031. if (a.middle) {
  3032. this.refreshHeaderRow("middle")
  3033. }
  3034. if (a.bottom) {
  3035. this.refreshHeaderRow("bottom")
  3036. }
  3037. },
  3038. refreshHeaderRow : function(a, b) {
  3039. var e = this.el;
  3040. var f = this.columnConfig[a];
  3041. var d = this;
  3042. var c;
  3043. var g = a === "bottom" || (a === "middle" && !this.columnConfig.bottom);
  3044. b = b || e.down(".sch-header-row-" + a, true);
  3045. Ext.fly(b).setWidth(d.getTotalWidth());
  3046. Ext.fly(b).select(" thead > tr > td").each(function(i, j, h) {
  3047. c = g ? d.columnWidth : d.getHeaderGroupCellWidth(f[h].start,
  3048. f[h].end);
  3049. i.setVisibilityMode(Ext.Element.DISPLAY);
  3050. if (c) {
  3051. if (Ext.isSafari && Ext.isMac) {
  3052. c -= 2
  3053. }
  3054. i.show();
  3055. i.setWidth(c - (Ext.chromeVersion === 19 ? (h ? 1 : 0) : 0))
  3056. } else {
  3057. i.hide()
  3058. }
  3059. });
  3060. if (a === "bottom") {
  3061. if (c < this.compactCellWidthThreshold) {
  3062. Ext.fly(b).addCls("sch-header-row-compact")
  3063. } else {
  3064. Ext.fly(b).removeCls("sch-header-row-compact")
  3065. }
  3066. }
  3067. },
  3068. getHeaderGroupCellWidth : function(c, a) {
  3069. var b = this.getSchedulingView();
  3070. return b.getXYFromDate(a)[0] - b.getXYFromDate(c)[0]
  3071. },
  3072. onElDblClick : function(d, f) {
  3073. var e = d.getTarget(".sch-column-header");
  3074. if (e) {
  3075. var a = Ext.fly(e).getAttribute("headerPosition"), b = Ext.fly(e)
  3076. .getAttribute("headerIndex"), c = this.columnConfig[a][b];
  3077. this.fireEvent("timeheaderdblclick", this, c.start, c.end, d)
  3078. }
  3079. },
  3080. getTimeColumnWidth : function() {
  3081. if (this.columnWidth === null) {
  3082. this.columnWidth = this.getWidth() / this.nbrTimeColumns
  3083. }
  3084. return this.columnWidth
  3085. },
  3086. setTimeColumnWidth : function(a) {
  3087. this.columnWidth = a;
  3088. if (this.rendered) {
  3089. Ext.suspendLayouts();
  3090. this.setWidth(a * this.nbrTimeColumns);
  3091. Ext.resumeLayouts();
  3092. this.refreshHeaderSizes();
  3093. this.ownerCt.updateLayout()
  3094. } else {
  3095. this.setWidth(a * this.nbrTimeColumns)
  3096. }
  3097. },
  3098. getTotalWidth : function() {
  3099. return this.columnWidth * this.nbrTimeColumns
  3100. },
  3101. highlightCell : function(c, a) {
  3102. var b = this;
  3103. if (a !== b.highlightedCell) {
  3104. b.clearHighlight();
  3105. b.highlightedCell = a;
  3106. Ext.fly(a).addCls(b.ownHoverCls)
  3107. }
  3108. },
  3109. clearHighlight : function() {
  3110. var b = this, a = b.highlightedCell;
  3111. if (a) {
  3112. Ext.fly(a).removeCls(b.ownHoverCls);
  3113. delete b.highlightedCell
  3114. }
  3115. }
  3116. });
  3117. Ext.define("Sch.mixin.Lockable", {
  3118. extend : "Ext.grid.Lockable",
  3119. requires : ["Sch.column.timeAxis.Horizontal",
  3120. "Sch.column.timeAxis.HorizontalSingle"],
  3121. findEditingPlugin : function() {
  3122. var b = this.plugins || [];
  3123. var c = this;
  3124. var a;
  3125. Ext.each(b, function(e, d) {
  3126. if (Ext.grid.plugin && Ext.grid.plugin.CellEditing
  3127. && e instanceof Ext.grid.plugin.CellEditing) {
  3128. a = e;
  3129. Ext.Array.remove(b, e);
  3130. return false
  3131. }
  3132. });
  3133. return a
  3134. },
  3135. processSchedulerPlugins : function() {
  3136. var e = [];
  3137. var d = [];
  3138. var g = [];
  3139. var a = this.plugins || [];
  3140. var c = this;
  3141. for (var b = a.length - 1; b >= 0; b--) {
  3142. var f = a[b];
  3143. if (f.lockableScope) {
  3144. switch (f.lockableScope) {
  3145. case "top" :
  3146. g.push(f);
  3147. break;
  3148. case "locked" :
  3149. e.push(f);
  3150. break;
  3151. case "normal" :
  3152. d.push(f);
  3153. break
  3154. }
  3155. Ext.Array.remove(a, f)
  3156. }
  3157. }
  3158. if (e.length > 0) {
  3159. c.lockedGridConfig.plugins = (c.lockedGridConfig.plugins || [])
  3160. .concat(e)
  3161. }
  3162. if (d.length > 0) {
  3163. c.normalGridConfig.plugins = (c.normalGridConfig.plugins || [])
  3164. .concat(d)
  3165. }
  3166. c.topPlugins = g
  3167. },
  3168. injectLockable : function() {
  3169. var d = this.findEditingPlugin();
  3170. var k = this;
  3171. var g = Ext.data.TreeStore && k.store instanceof Ext.data.TreeStore;
  3172. var m = k.store.buffered;
  3173. var c = k.getEventSelectionModel ? k.getEventSelectionModel() : k
  3174. .getSelectionModel();
  3175. k.lockedGridConfig = Ext.apply({}, k.lockedGridConfig || {});
  3176. k.normalGridConfig = Ext.apply({}, k.schedulerConfig
  3177. || k.normalGridConfig || {});
  3178. var a = k.lockedGridConfig, j = k.normalGridConfig;
  3179. Ext.applyIf(k.lockedGridConfig, {
  3180. xtype : k.lockedXType,
  3181. id : k.id + "_locked",
  3182. enableLocking : false,
  3183. lockable : false,
  3184. useArrows : true,
  3185. columnLines : k.columnLines,
  3186. rowLines : k.rowLines,
  3187. stateful : k.stateful,
  3188. delayScroll : function() {
  3189. if (this.rendered) {
  3190. return this.self.prototype.delayScroll.apply(this,
  3191. arguments)
  3192. }
  3193. },
  3194. split : true,
  3195. animCollapse : false,
  3196. collapseDirection : "left",
  3197. region : "west"
  3198. });
  3199. if (d) {
  3200. k.lockedGridConfig.plugins = (k.lockedGridConfig.plugins || [])
  3201. .concat(d)
  3202. }
  3203. k.processSchedulerPlugins();
  3204. Ext.applyIf(k.normalGridConfig, {
  3205. xtype : k.normalXType,
  3206. enableLocking : false,
  3207. lockable : false,
  3208. viewType : k.viewType,
  3209. layout : "fit",
  3210. sortableColumns : false,
  3211. enableColumnMove : false,
  3212. enableColumnResize : false,
  3213. enableColumnHide : false,
  3214. selModel : c,
  3215. eventSelModel : c,
  3216. _top : k,
  3217. orientation : k.orientation,
  3218. viewPreset : k.viewPreset,
  3219. timeAxis : k.timeAxis,
  3220. columnLines : k.columnLines,
  3221. rowLines : k.rowLines,
  3222. collapseDirection : "right",
  3223. animCollapse : false,
  3224. region : "center"
  3225. });
  3226. k.bothCfgCopy = k.bothCfgCopy
  3227. || (Ext.grid.Panel && Ext.grid.Panel.prototype.bothCfgCopy)
  3228. || ["invalidateScrollerOnRefresh", "hideHeaders",
  3229. "enableColumnHide", "enableColumnMove",
  3230. "enableColumnResize", "sortableColumns"];
  3231. if (k.orientation === "vertical") {
  3232. a.store = j.store = k.timeAxis.tickStore;
  3233. k.mon(k.resourceStore, {
  3234. clear : k.refreshResourceColumns,
  3235. datachanged : k.refreshResourceColumns,
  3236. update : k.refreshResourceColumns,
  3237. load : k.refreshResourceColumns,
  3238. scope : k
  3239. })
  3240. }
  3241. if (a.width) {
  3242. k.syncLockedWidth = Ext.emptyFn;
  3243. a.scroll = "horizontal";
  3244. a.scrollerOwner = true
  3245. }
  3246. if (k.resourceStore) {
  3247. j.resourceStore = k.resourceStore
  3248. }
  3249. if (k.eventStore) {
  3250. j.eventStore = k.eventStore
  3251. }
  3252. if (k.dependencyStore) {
  3253. j.dependencyStore = k.dependencyStore
  3254. }
  3255. var e = k.lockedViewConfig = k.lockedViewConfig || {};
  3256. var l = k.normalViewConfig = k.normalViewConfig || {};
  3257. if (g && m && Ext.getScrollbarSize().width === 0) {
  3258. k.lockedGridConfig.scroll = "horizontal"
  3259. }
  3260. if (m) {
  3261. e.preserveScrollOnRefresh = true
  3262. }
  3263. e.enableAnimations = k.normalViewConfig.enableAnimations = false;
  3264. if (g) {
  3265. if (Ext.versions.extjs.isLessThan("4.1.3")) {
  3266. k.normalViewConfig.providedStore = e.providedStore = k.store.nodeStore
  3267. } else {
  3268. k.normalViewConfig.store = e.store = k.store.nodeStore
  3269. }
  3270. k.overrideNodeStore(k.store.nodeStore)
  3271. }
  3272. var f = k.layout;
  3273. this.callParent(arguments);
  3274. if (k.topPlugins) {
  3275. k.plugins = k.topPlugins
  3276. }
  3277. if (a.width) {
  3278. k.lockedGrid.setWidth(a.width);
  3279. k.normalGrid.getView().addCls("sch-timeline-horizontal-scroll");
  3280. k.lockedGrid.getView().addCls("sch-locked-horizontal-scroll")
  3281. } else {
  3282. if (k.normalGrid.collapsed) {
  3283. k.normalGrid.collapsed = false;
  3284. k.normalGrid.view.on("boxready", function() {
  3285. k.normalGrid.collapse()
  3286. }, k, {
  3287. delay : 10
  3288. })
  3289. }
  3290. }
  3291. var n = k.lockedGrid.getView();
  3292. var b = k.normalGrid.getView();
  3293. var h;
  3294. if (m) {
  3295. h = k.normalGrid.verticalScroller;
  3296. n.on("render", this.onLockedViewRender, this);
  3297. this.fixPagingScroller(h);
  3298. if (Ext.getVersion("extjs").isLessThan("4.1.1")) {
  3299. if (Ext.getScrollbarSize().width > 0) {
  3300. n.on({
  3301. scroll : {
  3302. fn : k.onLockedViewScroll,
  3303. element : "el",
  3304. scope : k
  3305. }
  3306. })
  3307. }
  3308. }
  3309. }
  3310. if (Ext.getScrollbarSize().width === 0) {
  3311. n.addCls("sch-ganttpanel-force-locked-scroll")
  3312. }
  3313. if (g) {
  3314. this.setupLockableTree()
  3315. }
  3316. if (!b.deferInitialRefresh) {
  3317. var i = b.onRender;
  3318. b.onRender = function() {
  3319. this.doFirstRefresh = function() {
  3320. };
  3321. i.apply(this, arguments);
  3322. delete this.doFirstRefresh
  3323. }
  3324. }
  3325. if (m) {
  3326. b.el = {
  3327. un : function() {
  3328. }
  3329. };
  3330. h.bindView(b);
  3331. b.un("refresh", h.self.prototype.onViewRefresh, h);
  3332. delete b.el
  3333. }
  3334. k.view.clearListeners();
  3335. n.on({
  3336. refresh : k.updateSpacer,
  3337. scope : k
  3338. });
  3339. if (!Ext.grid.Lockable.prototype.updateSpacer) {
  3340. b.on({
  3341. refresh : k.updateSpacer,
  3342. scope : k
  3343. })
  3344. }
  3345. k.view = Ext.create("Sch.view.Locking", {
  3346. locked : k.lockedGrid,
  3347. normal : k.normalGrid,
  3348. panel : k
  3349. });
  3350. if (k.syncRowHeight) {
  3351. n.on("refresh", this.onLockedViewRefresh, this);
  3352. if (g) {
  3353. k.mon(k.store, {
  3354. beforeload : function() {
  3355. n.un({
  3356. itemadd : k.onViewItemAdd,
  3357. scope : k
  3358. });
  3359. b.un({
  3360. itemadd : k.onViewItemAdd,
  3361. scope : k
  3362. })
  3363. },
  3364. load : function() {
  3365. n.un({
  3366. itemadd : k.onViewItemAdd,
  3367. scope : k
  3368. });
  3369. b.un({
  3370. itemadd : k.onViewItemAdd,
  3371. scope : k
  3372. });
  3373. k.prepareFullRowHeightSync();
  3374. k.syncRowHeights()
  3375. }
  3376. });
  3377. k.normalGrid.on("afteritemexpand", k.afterNormalGridItemExpand,
  3378. k)
  3379. }
  3380. n.on({
  3381. itemadd : k.onViewItemAdd,
  3382. scope : k
  3383. });
  3384. b.on({
  3385. itemadd : k.onViewItemAdd,
  3386. itemupdate : k.onNormalViewItemUpdate,
  3387. groupexpand : k.onNormalViewGroupExpand,
  3388. scope : k
  3389. });
  3390. if (Ext.isIE9 && Ext.isStrict) {
  3391. k.onNormalViewItemUpdate = function(o, p, r) {
  3392. r = r.dom ? r.dom : r;
  3393. if (k.lockedGridDependsOnSchedule) {
  3394. var q = k.lockedGrid.getView();
  3395. q.suspendEvents();
  3396. q.onUpdate(k.lockedGrid.store, o);
  3397. q.resumeEvents()
  3398. }
  3399. var s = k.normalGrid.getView().getNode(p);
  3400. s.style.height = r.style.height;
  3401. k.normalHeights[p] = r.style.height;
  3402. k.syncRowHeights()
  3403. }
  3404. }
  3405. }
  3406. if (f !== "fit") {
  3407. k.layout = f
  3408. }
  3409. k.normalGrid.on({
  3410. collapse : k.onNormalGridCollapse,
  3411. expand : k.onNormalGridExpand,
  3412. scope : k
  3413. });
  3414. k.lockedGrid.on({
  3415. collapse : k.onLockedGridCollapse,
  3416. scope : k
  3417. });
  3418. if (this.lockedGrid.view.store !== this.normalGrid.view.store) {
  3419. Ext.Error
  3420. .raise("Sch.mixin.Lockable setup failed, not sharing store between the two views")
  3421. }
  3422. },
  3423. onLockedGridCollapse : function() {
  3424. if (this.normalGrid.collapsed) {
  3425. this.normalGrid.expand()
  3426. }
  3427. },
  3428. onNormalGridCollapse : function() {
  3429. var a = this;
  3430. if (!a.normalGrid.reExpander) {
  3431. a.normalGrid.reExpander = a.normalGrid.placeholder
  3432. }
  3433. if (!a.lockedGrid.rendered) {
  3434. a.lockedGrid.on("render", a.onNormalGridCollapse, a, {
  3435. delay : 1
  3436. })
  3437. } else {
  3438. a.lastLockedWidth = a.lockedGrid.getWidth();
  3439. a.lockedGrid.setWidth(a.getWidth() - 35);
  3440. if (a.lockedGrid.collapsed) {
  3441. a.lockedGrid.expand()
  3442. }
  3443. a.addCls("sch-normalgrid-collapsed")
  3444. }
  3445. },
  3446. onNormalGridExpand : function() {
  3447. this.removeCls("sch-normalgrid-collapsed");
  3448. this.lockedGrid.setWidth(this.lastLockedWidth)
  3449. },
  3450. fixPagingScroller : function(a) {
  3451. var b = a.onViewRefresh;
  3452. a.onViewRefresh = function() {
  3453. 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;
  3454. if (j.focusOnRefresh) {
  3455. o.focus();
  3456. j.focusOnRefresh = false
  3457. }
  3458. j.disabled = true;
  3459. var f = l.getCount() === l.getTotalCount();
  3460. j.stretcher.setHeight(i = j.getScrollHeight());
  3461. g = p.scrollTop;
  3462. j.isScrollRefresh = (g > 0);
  3463. if (j.scrollProportion !== undefined) {
  3464. j.setTablePosition("absolute");
  3465. j.setTableTop((j.scrollProportion && j.tableStart > 0
  3466. ? (i * j.scrollProportion)
  3467. - (q.offsetHeight * j.scrollProportion)
  3468. : 0)
  3469. + "px")
  3470. } else {
  3471. j.setTablePosition("absolute");
  3472. j.setTableTop((m = (j.tableStart || 0) * j.rowHeight) + "px");
  3473. if (j.scrollOffset) {
  3474. r = k.getNodes();
  3475. n = -o.getOffsetsTo(r[j.commonRecordIndex])[1];
  3476. h = n - j.scrollOffset;
  3477. j.position = (p.scrollTop += h)
  3478. } else {
  3479. if ((m > g) || ((m + q.offsetHeight) < g + p.clientHeight)) {
  3480. if (!(f && !m)) {
  3481. j.lastScrollDirection = -1;
  3482. j.position = p.scrollTop = m
  3483. }
  3484. }
  3485. }
  3486. }
  3487. j.disabled = false
  3488. };
  3489. a.setViewTableStyle = function(f, h, g) {
  3490. if (f.table.dom) {
  3491. f.table.dom.style[h] = g
  3492. }
  3493. f = f.lockingPartner;
  3494. if (f) {
  3495. if (f.table.dom) {
  3496. f.table.dom.style[h] = g
  3497. }
  3498. }
  3499. };
  3500. var d = a.view.lockingPartner;
  3501. if (d) {
  3502. var e = a.onLockRefresh;
  3503. var c = function(f) {
  3504. if (f.table.dom) {
  3505. e.apply(this, arguments)
  3506. }
  3507. };
  3508. d.un("refresh", e, a);
  3509. d.on("refresh", c, a);
  3510. a.onLockRefresh = c
  3511. }
  3512. a.view.un("render", a.onViewRender, a);
  3513. a.onViewRender = function() {
  3514. var g = this, f = g.view.el;
  3515. f.setStyle("position", "relative");
  3516. g.stretcher = f.createChild({
  3517. style : {
  3518. position : "absolute",
  3519. width : "1px",
  3520. height : 0,
  3521. top : 0,
  3522. left : 0
  3523. }
  3524. }, f.dom.firstChild)
  3525. };
  3526. a.view.on("render", a.onViewRender, a);
  3527. if (Ext.getVersion("extjs").isLessThan("4.1.3")) {
  3528. a.scrollTo = function(m, g, p, r) {
  3529. var j = this, l = j.view, q = l.el.dom, n = j.store, k = n
  3530. .getTotalCount(), i, f, h, o;
  3531. m = Math.min(Math.max(m, 0), k - 1);
  3532. i = Math
  3533. .max(
  3534. Math
  3535. .min(
  3536. m
  3537. - ((j.leadingBufferZone + j.trailingBufferZone) / 2),
  3538. k - j.viewSize + 1), 0);
  3539. o = i * j.rowHeight;
  3540. f = i + j.viewSize - 1;
  3541. j.lastScrollDirection = undefined;
  3542. j.disabled = true;
  3543. n.guaranteeRange(i, f, function() {
  3544. h = n.pageMap.getRange(m, m)[0];
  3545. l.table.dom.style.top = o + "px";
  3546. q.scrollTop = o = Math.min(Math.max(0,
  3547. o
  3548. - l.table.getOffsetsTo(l
  3549. .getNode(h))[1]),
  3550. q.scrollHeight - q.clientHeight);
  3551. if (Ext.isIE) {
  3552. q.scrollTop = o
  3553. }
  3554. j.disabled = false;
  3555. if (g) {
  3556. j.grid.selModel.select(h)
  3557. }
  3558. if (p) {
  3559. p.call(r || j, m, h)
  3560. }
  3561. })
  3562. }
  3563. }
  3564. },
  3565. onLockedViewScroll : function() {
  3566. if (this.store.buffered) {
  3567. var a = this.normalGrid.getView().el;
  3568. if (!a || !a.child("table", true)) {
  3569. return
  3570. }
  3571. }
  3572. return this.callParent(arguments)
  3573. },
  3574. onNormalViewScroll : function() {
  3575. if (this.store.buffered) {
  3576. var a = this.lockedGrid.getView().el;
  3577. if (!a || !a.child("table", true)) {
  3578. return
  3579. }
  3580. }
  3581. return this.callParent(arguments)
  3582. },
  3583. setupLockableTree : function() {
  3584. var h = this;
  3585. var i = h.store.buffered;
  3586. var c = h.getView();
  3587. var l = h.lockedGrid.getView();
  3588. var d = h.normalGrid.getView();
  3589. var j = d.store;
  3590. var b = h.store;
  3591. var e = Sch.mixin.FilterableTreeView.prototype;
  3592. l.initTreeFiltering = e.initTreeFiltering;
  3593. l.onFilterChangeStart = e.onFilterChangeStart;
  3594. l.onFilterChangeEnd = e.onFilterChangeEnd;
  3595. l.onFilterCleared = e.onFilterCleared;
  3596. l.onFilterSet = e.onFilterSet;
  3597. l.initTreeFiltering();
  3598. if (i) {
  3599. b.on("nodestore-datachange-end", function() {
  3600. if (d.rendered) {
  3601. h.onNormalViewScroll()
  3602. }
  3603. })
  3604. } else {
  3605. this.mon(b, {
  3606. "root-fill-start" : function() {
  3607. j.suspendEvents()
  3608. },
  3609. "root-fill-end" : function() {
  3610. j.resumeEvents();
  3611. c.refresh()
  3612. }
  3613. })
  3614. }
  3615. this.mon(b, "filter", function(n, m) {
  3616. j.filter.apply(j, m);
  3617. c.refresh()
  3618. });
  3619. this.mon(b, "clearfilter", function(m) {
  3620. j.clearFilter();
  3621. c.refresh()
  3622. });
  3623. var g = h.normalGrid.verticalScroller;
  3624. if (i && g) {
  3625. var a = g.onGuaranteedRange;
  3626. g.onGuaranteedRange = function() {
  3627. a.apply(this, arguments);
  3628. Ext.suspendLayouts();
  3629. c.refresh();
  3630. Ext.resumeLayouts()
  3631. }
  3632. }
  3633. var k = l.onAdd;
  3634. var f = l.onRemove;
  3635. l.onAdd = function() {
  3636. Ext.suspendLayouts();
  3637. k.apply(this, arguments);
  3638. Ext.resumeLayouts()
  3639. };
  3640. l.onRemove = function() {
  3641. Ext.suspendLayouts();
  3642. f.apply(this, arguments);
  3643. Ext.resumeLayouts()
  3644. }
  3645. },
  3646. onNormalViewItemUpdate : function(a, b, d) {
  3647. d = d.dom ? d.dom : d;
  3648. if (this.lockedGridDependsOnSchedule) {
  3649. var c = this.lockedGrid.getView();
  3650. c.suspendEvents();
  3651. c.onUpdate(this.lockedGrid.store, a);
  3652. c.resumeEvents()
  3653. }
  3654. var f = this.normalGrid.getView().getNode(b);
  3655. var e = f.style.height !== d.style.height;
  3656. f.style.height = d.style.height;
  3657. this.normalHeights[b] = d.style.height;
  3658. this.syncRowHeights(e)
  3659. },
  3660. afterNormalGridItemExpand : function(a) {
  3661. var c = this;
  3662. var b = c.getSchedulingView();
  3663. a.cascadeBy(function(f) {
  3664. if (f !== a) {
  3665. var e = b.getNode(f);
  3666. if (e) {
  3667. var d = b.indexOf(e);
  3668. c.normalHeights[d] = e.style.height
  3669. }
  3670. }
  3671. });
  3672. c.syncRowHeights(true)
  3673. },
  3674. onViewItemAdd : function(c, d, b) {
  3675. var e = this.normalGrid.getView();
  3676. var f = this.lockedGrid.getView();
  3677. if (e.getNodes().length !== f.getNodes().length) {
  3678. return
  3679. }
  3680. var a = this.normalHeights;
  3681. Ext.each(c, function(h, g) {
  3682. var i = e.getNode(h);
  3683. if (i) {
  3684. a[i.viewIndex] = i.style.height
  3685. }
  3686. });
  3687. this.syncRowHeights()
  3688. },
  3689. processColumns : function(b) {
  3690. var a = this.callParent(arguments);
  3691. var c = [];
  3692. Ext.each(b, function(d) {
  3693. if (d.position == "right") {
  3694. d.processed = true;
  3695. if (!Ext.isNumber(d.width)) {
  3696. Ext.Error
  3697. .raise('"Right" columns must have a fixed width')
  3698. }
  3699. c.push(d);
  3700. Ext.Array.remove(a.locked.items, d);
  3701. a.lockedWidth -= d.width
  3702. }
  3703. });
  3704. if (this.orientation === "horizontal") {
  3705. a.normal.items = [{
  3706. xtype : this.lightWeight
  3707. ? "singletimeaxiscolumn"
  3708. : "timeaxiscolumn",
  3709. timeAxis : this.timeAxis,
  3710. timeCellRenderer : this.timeCellRenderer,
  3711. timeCellRendererScope : this.timeCellRendererScope,
  3712. trackHeaderOver : this.trackHeaderOver
  3713. }].concat(c)
  3714. } else {
  3715. a.locked.items = [Ext.apply({
  3716. xtype : "verticaltimeaxis",
  3717. width : 100,
  3718. timeAxis : this.timeAxis
  3719. }, this.timeAxisColumnCfg || {})];
  3720. a.lockedWidth = a.locked.items[0].width
  3721. }
  3722. return a
  3723. },
  3724. prepareFullRowHeightSync : function() {
  3725. var g = this, h = g.normalGrid.getView(), j = g.lockedGrid.getView();
  3726. if (!h.rendered || !j.rendered) {
  3727. return
  3728. }
  3729. var a = h.el, d = j.el, f = a.query(h.getItemSelector()), b = d.query(j
  3730. .getItemSelector()), e = f.length, c = 0;
  3731. g.lockedHeights = [];
  3732. g.normalHeights = [];
  3733. if (b.length !== e) {
  3734. return
  3735. }
  3736. for (; c < e; c++) {
  3737. g.normalHeights[c] = f[c].style.height
  3738. }
  3739. },
  3740. onLockedViewRefresh : function() {
  3741. this.prepareFullRowHeightSync();
  3742. this.syncRowHeights()
  3743. },
  3744. onNormalViewRefresh : function() {
  3745. var a = this.lockedGrid.getView();
  3746. if (this.lockedGridDependsOnSchedule) {
  3747. a.un("refresh", this.onLockedViewRefresh, this);
  3748. this.lockedGrid.getView().refresh();
  3749. a.on("refresh", this.onLockedViewRefresh, this)
  3750. }
  3751. this.prepareFullRowHeightSync();
  3752. this.syncRowHeights()
  3753. },
  3754. syncRowHeights : function(b) {
  3755. if (!this.lockedGrid.getView().rendered
  3756. || !this.normalGrid.getView().rendered) {
  3757. return
  3758. }
  3759. var j = this, c = j.lockedHeights, k = j.normalHeights, a = [], h = c.length
  3760. || k.length, f = 0, l, d, e, g;
  3761. if (c.length || k.length) {
  3762. l = j.lockedGrid.getView();
  3763. d = j.normalGrid.getView();
  3764. e = l.el.query(l.getItemSelector());
  3765. g = d.el.query(d.getItemSelector());
  3766. if (g.length !== e.length) {
  3767. return
  3768. }
  3769. for (; f < h; f++) {
  3770. if (e[f] && k[f]) {
  3771. e[f].style.height = k[f]
  3772. }
  3773. }
  3774. j.lockedHeights = [];
  3775. j.normalHeights = []
  3776. }
  3777. if (b !== false) {
  3778. j.updateSpacer()
  3779. }
  3780. },
  3781. getMenuItems : function() {
  3782. if (Ext.versions.extjs.isGreaterThanOrEqual("4.1.2")) {
  3783. return this.callParent(arguments)
  3784. }
  3785. return function() {
  3786. return Ext.grid.header.Container.prototype.getMenuItems.apply(this,
  3787. arguments)
  3788. }
  3789. },
  3790. applyColumnsState : Ext.emptyFn,
  3791. updateSpacer : function() {
  3792. var g = this.lockedGrid.getView();
  3793. var e = this.normalGrid.getView();
  3794. if (g.rendered && e.rendered && g.el.child("table")
  3795. && !this.getSchedulingView().__lightRefresh) {
  3796. var f = this, c = g.el, d = e.el.dom, b = c.dom.id + "-spacer", h = (d.offsetHeight - d.clientHeight)
  3797. + "px";
  3798. f.spacerEl = Ext.getDom(b);
  3799. if (Ext.isIE6 || Ext.isIE7 || (Ext.isIEQuirks && Ext.isIE8)
  3800. && f.spacerEl) {
  3801. Ext.removeNode(f.spacerEl);
  3802. f.spacerEl = null
  3803. }
  3804. if (f.spacerEl) {
  3805. f.spacerEl.style.height = h
  3806. } else {
  3807. var a;
  3808. if (this.store.buffered) {
  3809. a = f.normalGrid.verticalScroller.stretcher.item(0).dom.parentNode === c.dom
  3810. ? f.normalGrid.verticalScroller.stretcher.item(0)
  3811. : f.normalGrid.verticalScroller.stretcher.item(1)
  3812. } else {
  3813. a = c
  3814. }
  3815. Ext.core.DomHelper.append(a, {
  3816. id : b,
  3817. cls : this.store.buffered
  3818. ? "sch-locked-buffered-spacer"
  3819. : "",
  3820. style : "height: " + h
  3821. })
  3822. }
  3823. }
  3824. },
  3825. onLockedViewRender : function() {
  3826. var e = this.normalGrid;
  3827. if (!this.lockedStretcher) {
  3828. var c = this.lockedGrid.getView().el;
  3829. var a = this.lockedStretcher = c.createChild({
  3830. cls : "x-stretcher",
  3831. style : {
  3832. position : "absolute",
  3833. width : "1px",
  3834. height : 0,
  3835. top : 0,
  3836. left : 0
  3837. }
  3838. }, c.dom.firstChild)
  3839. }
  3840. if (!e.rendered) {
  3841. e.getView().on("render", this.onLockedViewRender, this);
  3842. return
  3843. }
  3844. var d = this;
  3845. setTimeout(function() {
  3846. var f = e.getView().el;
  3847. if (f && f.dom) {
  3848. e.getView().el.un("scroll", d.onNormalViewScroll, d);
  3849. e.getView().el.on("scroll", d.onNormalViewScroll, d)
  3850. }
  3851. }, 0);
  3852. var b = e.verticalScroller;
  3853. b.stretcher.addCls("x-stretcher");
  3854. b.stretcher = new Ext.dom.CompositeElement([this.lockedStretcher,
  3855. b.stretcher])
  3856. },
  3857. onNormalViewGroupExpand : function() {
  3858. this.prepareFullRowHeightSync();
  3859. this.syncRowHeights()
  3860. },
  3861. overrideNodeStore : function(c) {
  3862. var a = c.onNodeCollapse;
  3863. var b = c.onNodeExpand;
  3864. c.onNodeCollapse = function() {
  3865. Ext.suspendLayouts();
  3866. a.apply(this, arguments);
  3867. Ext.resumeLayouts()
  3868. };
  3869. c.onNodeExpand = function() {
  3870. Ext.suspendLayouts();
  3871. b.apply(this, arguments);
  3872. Ext.resumeLayouts()
  3873. }
  3874. }
  3875. });
  3876. Ext.define("Sch.plugin.TreeCellEditing", {
  3877. extend : "Ext.grid.plugin.CellEditing",
  3878. init : function(a) {
  3879. this._grid = a;
  3880. this.on("beforeedit", this.checkReadOnly, this);
  3881. this.callParent(arguments)
  3882. },
  3883. checkReadOnly : function() {
  3884. var a = this._grid;
  3885. if (!(a instanceof Sch.panel.TimelineTreePanel)) {
  3886. a = a.up("tablepanel")
  3887. }
  3888. return !a.isReadOnly()
  3889. },
  3890. startEditByClick : function(c, a, h, b, g, d, f) {
  3891. if (f.getTarget(c.expanderSelector)) {
  3892. return
  3893. }
  3894. this.callParent(arguments)
  3895. },
  3896. startEdit : function(a, f) {
  3897. if (!a || !f) {
  3898. return
  3899. }
  3900. var d = this, b = d.getEditor(a, f), e = a.get(f.dataIndex), c = d
  3901. .getEditingContext(a, f);
  3902. a = c.record;
  3903. f = c.column;
  3904. d.completeEdit();
  3905. if (f && !f.getEditor(a)) {
  3906. return false
  3907. }
  3908. if (b) {
  3909. c.originalValue = c.value = e;
  3910. if (d.beforeEdit(c) === false
  3911. || d.fireEvent("beforeedit", c) === false || c.cancel) {
  3912. return false
  3913. }
  3914. d.context = c;
  3915. d.setActiveEditor(b);
  3916. d.setActiveRecord(a);
  3917. d.setActiveColumn(f);
  3918. d.grid.view.focusCell({
  3919. column : c.colIdx,
  3920. row : c.rowIdx
  3921. });
  3922. d.editTask.delay(15, d.showEditor, d, [b, c, c.value])
  3923. } else {
  3924. d.grid.getView().getEl(f).focus((Ext.isWebKit || Ext.isIE)
  3925. ? 10
  3926. : false)
  3927. }
  3928. },
  3929. showEditor : function(b, c, g) {
  3930. var e = this, a = c.record, f = c.column, h = e.grid
  3931. .getSelectionModel(), d = h.getCurrentPosition
  3932. && h.getCurrentPosition();
  3933. e.context = c;
  3934. e.setActiveEditor(b);
  3935. e.setActiveRecord(a);
  3936. e.setActiveColumn(f);
  3937. if (h.selectByPosition
  3938. && (!d || d.column !== c.colIdx || d.row !== c.rowIdx)) {
  3939. h.selectByPosition({
  3940. row : c.rowIdx,
  3941. column : c.colIdx
  3942. })
  3943. }
  3944. b.startEdit(e.getCell(a, f), g, c);
  3945. e.editing = true;
  3946. e.scroll = e.view.el.getScroll()
  3947. },
  3948. getEditingContext : function(e, c) {
  3949. var f = this, a = f.grid, i = a.store, b, d, g = a.getView(), h;
  3950. if (Ext.isNumber(e)) {
  3951. b = e;
  3952. e = i.getAt(b)
  3953. } else {
  3954. if (i instanceof Ext.data.Store) {
  3955. b = i.indexOf(e)
  3956. } else {
  3957. b = g.indexOf(g.getNode(e))
  3958. }
  3959. }
  3960. if (Ext.isNumber(c)) {
  3961. d = c;
  3962. c = a.headerCt.getHeaderAtIndex(d)
  3963. } else {
  3964. d = c.getIndex()
  3965. }
  3966. h = e.get(c.dataIndex);
  3967. return {
  3968. grid : a,
  3969. record : e,
  3970. field : c.dataIndex,
  3971. value : h,
  3972. row : g.getNode(b),
  3973. column : c,
  3974. rowIdx : b,
  3975. colIdx : d
  3976. }
  3977. },
  3978. startEditByPosition : function(a) {
  3979. var f = this, d = f.grid, h = d.getSelectionModel(), b = f.view, e = this.view
  3980. .getNode(a.row), g = d.headerCt.getHeaderAtIndex(a.column), c = b
  3981. .getRecord(e);
  3982. if (h.selectByPosition) {
  3983. h.selectByPosition(a)
  3984. }
  3985. f.startEdit(c, g)
  3986. },
  3987. onEditComplete : function(c, g, b) {
  3988. var f = this, d = f.grid, e = f.getActiveColumn(), h = d
  3989. .getSelectionModel(), a;
  3990. if (e) {
  3991. a = f.context.record;
  3992. f.setActiveEditor(null);
  3993. f.setActiveColumn(null);
  3994. f.setActiveRecord(null);
  3995. if (!f.validateEdit()) {
  3996. return
  3997. }
  3998. if (!f.context.doNotUpdateRecord && !a.isEqual(g, b)) {
  3999. a.set(e.dataIndex, g)
  4000. }
  4001. if (h.setCurrentPosition) {
  4002. h.setCurrentPosition(h.getCurrentPosition())
  4003. }
  4004. d.getView().getEl(e).focus();
  4005. f.context.value = g;
  4006. f.fireEvent("edit", f, f.context)
  4007. }
  4008. },
  4009. onSpecialKey : function(a, f, d) {
  4010. if (!Ext.versions.extjs.equals("4.1.2.381")) {
  4011. return this.callParent(arguments)
  4012. }
  4013. var c = this, b = this.grid, g;
  4014. if (d.getKey() === d.TAB) {
  4015. d.stopEvent();
  4016. if (a) {
  4017. a.onEditorTab(d)
  4018. }
  4019. g = b.getSelectionModel();
  4020. if (g.onEditorTab) {
  4021. return g.onEditorTab(b === c.grid ? c : c.lockingPartner, d)
  4022. }
  4023. }
  4024. }
  4025. });
  4026. Ext.define("Sch.feature.ColumnLines", {
  4027. extend : "Sch.plugin.Lines",
  4028. cls : "sch-column-line",
  4029. showTip : false,
  4030. requires : ["Ext.data.Store"],
  4031. init : function(b) {
  4032. this.timeAxis = b.getTimeAxis();
  4033. this.store = Ext.create("Ext.data.JsonStore", {
  4034. model : Ext.define("Sch.model.TimeLine", {
  4035. extend : "Ext.data.Model",
  4036. fields : ["start", {
  4037. name : "Date",
  4038. convert : function(d, c) {
  4039. return c.data.start
  4040. }
  4041. }]
  4042. }),
  4043. data : b.getOrientation() === "horizontal" ? this
  4044. .getData() : []
  4045. });
  4046. this.callParent(arguments);
  4047. var a = this.schedulerView;
  4048. a.timeAxis.on("reconfigure", this.populate, this)
  4049. },
  4050. populate : function() {
  4051. var a = this.schedulerView;
  4052. var b = a.getOrientation() === "horizontal"
  4053. && a.store.getCount() > 0;
  4054. this.store.removeAll(b);
  4055. if (b) {
  4056. this.store.add(this.getData())
  4057. }
  4058. },
  4059. getElementData : function() {
  4060. var a = this.schedulerView;
  4061. if (a.getOrientation() === "horizontal"
  4062. && a.store.getCount() > 0) {
  4063. return this.callParent(arguments)
  4064. }
  4065. return []
  4066. },
  4067. getData : function() {
  4068. var a = [];
  4069. this.timeAxis.forEachMainInterval(function(d, b, c) {
  4070. if (c > 0) {
  4071. a.push({
  4072. start : d
  4073. })
  4074. }
  4075. });
  4076. a.push({
  4077. start : this.timeAxis.getEnd()
  4078. });
  4079. return a
  4080. }
  4081. });
  4082. Ext.define("Sch.plugin.CurrentTimeLine", {
  4083. extend : "Sch.plugin.Lines",
  4084. tooltipText : "Current time",
  4085. updateInterval : 60000,
  4086. autoUpdate : true,
  4087. expandToFitView : true,
  4088. init : function(c) {
  4089. var b = Ext.create("Ext.data.JsonStore", {
  4090. fields : ["Date", "Cls", "Text"],
  4091. data : [{
  4092. Date : new Date(),
  4093. Cls : "sch-todayLine",
  4094. Text : this.tooltipText
  4095. }]
  4096. });
  4097. var a = b.first();
  4098. if (this.autoUpdate) {
  4099. this.runner = Ext.create("Ext.util.TaskRunner");
  4100. this.runner.start({
  4101. run : function() {
  4102. a.set("Date", new Date())
  4103. },
  4104. interval : this.updateInterval
  4105. })
  4106. }
  4107. c.on("destroy", this.onHostDestroy, this);
  4108. this.store = b;
  4109. this.callParent(arguments)
  4110. },
  4111. onHostDestroy : function() {
  4112. if (this.runner) {
  4113. this.runner.stopAll()
  4114. }
  4115. if (this.store.autoDestroy) {
  4116. this.store.destroy()
  4117. }
  4118. }
  4119. });
  4120. Ext.define("Sch.mixin.TimelineView", {
  4121. requires : ["Sch.column.Time", "Sch.data.TimeAxis"],
  4122. orientation : "horizontal",
  4123. overScheduledEventClass : "sch-event-hover",
  4124. selectedEventCls : "sch-event-selected",
  4125. altColCls : "sch-col-alt",
  4126. timeCellCls : "sch-timetd",
  4127. timeCellSelector : ".sch-timetd",
  4128. ScheduleEventMap : {
  4129. click : "Click",
  4130. mousedown : "MouseDown",
  4131. mouseup : "MouseUp",
  4132. dblclick : "DblClick",
  4133. contextmenu : "ContextMenu",
  4134. keydown : "KeyDown",
  4135. keyup : "KeyUp"
  4136. },
  4137. suppressFitCheck : 0,
  4138. forceFit : false,
  4139. inheritables : function() {
  4140. return {
  4141. cellBorderWidth : 1,
  4142. initComponent : function() {
  4143. this.setOrientation(this.panel._top.orientation
  4144. || this.orientation);
  4145. this.addEvents("beforetooltipshow", "scheduleclick",
  4146. "scheduledblclick", "schedulecontextmenu",
  4147. "columnwidthchange");
  4148. this.enableBubble("columnwidthchange");
  4149. var a = {}, c = Sch.util.Date;
  4150. a[c.DAY] = a[c.WEEK] = a[c.MONTH] = a[c.QUARTER] = a[c.YEAR] = null;
  4151. Ext.applyIf(this, {
  4152. eventPrefix : this.id + "-",
  4153. largeUnits : a
  4154. });
  4155. this.callParent(arguments);
  4156. if (this.orientation === "horizontal") {
  4157. this.getTimeAxisColumn().on("timeaxiscolumnreconfigured",
  4158. this.checkHorizontalFit, this)
  4159. }
  4160. var b = this.panel._top;
  4161. Ext.apply(this, {
  4162. eventRendererScope : b.eventRendererScope,
  4163. eventRenderer : b.eventRenderer,
  4164. eventBorderWidth : b.eventBorderWidth,
  4165. timeAxis : b.timeAxis,
  4166. dndValidatorFn : b.dndValidatorFn || Ext.emptyFn,
  4167. resizeValidatorFn : b.resizeValidatorFn
  4168. || Ext.emptyFn,
  4169. createValidatorFn : b.createValidatorFn
  4170. || Ext.emptyFn,
  4171. tooltipTpl : b.tooltipTpl,
  4172. validatorFnScope : b.validatorFnScope || this,
  4173. snapToIncrement : b.snapToIncrement,
  4174. timeCellRenderer : b.timeCellRenderer,
  4175. timeCellRendererScope : b.timeCellRendererScope,
  4176. readOnly : b.readOnly,
  4177. eventResizeHandles : b.eventResizeHandles,
  4178. enableEventDragDrop : b.enableEventDragDrop,
  4179. enableDragCreation : b.enableDragCreation,
  4180. dragConfig : b.dragConfig,
  4181. dropConfig : b.dropConfig,
  4182. resizeConfig : b.resizeConfig,
  4183. createConfig : b.createConfig,
  4184. tipCfg : b.tipCfg,
  4185. orientation : b.orientation,
  4186. getDateConstraints : b.getDateConstraints
  4187. || Ext.emptyFn
  4188. });
  4189. if (this.emptyText) {
  4190. this.emptyText = '<span class="sch-empty-text">'
  4191. + this.emptyText + "</span>"
  4192. }
  4193. },
  4194. onDestroy : function() {
  4195. if (this.tip) {
  4196. this.tip.destroy()
  4197. }
  4198. this.callParent(arguments)
  4199. },
  4200. afterComponentLayout : function() {
  4201. this.callParent(arguments);
  4202. var b = this.getWidth();
  4203. var a = this.getHeight();
  4204. if (b === this.__prevWidth && a === this.__prevHeight) {
  4205. return
  4206. }
  4207. this.__prevWidth = b;
  4208. this.__prevHeight = a;
  4209. if (!this.lockable && !this.suppressFitCheck) {
  4210. this.checkHorizontalFit()
  4211. }
  4212. },
  4213. beforeRender : function() {
  4214. this.callParent(arguments);
  4215. this.addCls("sch-timelineview");
  4216. if (this.readOnly) {
  4217. this.addCls(this._cmpCls + "-readonly")
  4218. }
  4219. },
  4220. afterRender : function() {
  4221. this.callParent(arguments);
  4222. if (this.overScheduledEventClass) {
  4223. this.mon(this.el, {
  4224. mouseover : this.onMouseOver,
  4225. mouseout : this.onMouseOut,
  4226. delegate : this.eventSelector,
  4227. scope : this
  4228. })
  4229. }
  4230. if (this.tooltipTpl) {
  4231. this.el.on("mousemove", this.setupTooltip, this, {
  4232. single : true
  4233. })
  4234. }
  4235. this.setupTimeCellEvents()
  4236. },
  4237. processUIEvent : function(f) {
  4238. var c = this, a = f.getTarget(this.eventSelector), d = c.ScheduleEventMap, b = f.type, g = false;
  4239. if (a && b in d) {
  4240. this.fireEvent(this.scheduledEventName + b, this, this
  4241. .resolveEventRecord(a), f);
  4242. g = !(this.panel.getSelectionModel() instanceof Ext.selection.RowModel)
  4243. }
  4244. if (!g) {
  4245. this.callParent(arguments)
  4246. }
  4247. },
  4248. refresh : function() {
  4249. this.fixedNodes = 0;
  4250. this.callParent(arguments)
  4251. },
  4252. clearViewEl : function() {
  4253. var c = this, b = c.getTargetEl();
  4254. b.down("table").remove();
  4255. if (this.emptyText) {
  4256. var a = b.down(".sch-empty-text");
  4257. if (a) {
  4258. a.remove()
  4259. }
  4260. }
  4261. },
  4262. onMouseOver : function(b, a) {
  4263. if (a !== this.lastItem) {
  4264. this.lastItem = a;
  4265. Ext.fly(a).addCls(this.overScheduledEventClass);
  4266. this.fireEvent("eventmouseenter", this, this
  4267. .resolveEventRecord(a), b)
  4268. }
  4269. },
  4270. onMouseOut : function(b, a) {
  4271. if (this.lastItem) {
  4272. if (!b.within(this.lastItem, true, true)) {
  4273. Ext.fly(this.lastItem)
  4274. .removeCls(this.overScheduledEventClass);
  4275. this.fireEvent("eventmouseleave", this, this
  4276. .resolveEventRecord(this.lastItem), b);
  4277. delete this.lastItem
  4278. }
  4279. }
  4280. },
  4281. highlightItem : function(b) {
  4282. if (b) {
  4283. var a = this;
  4284. a.clearHighlight();
  4285. a.highlightedItem = b;
  4286. Ext.fly(b).addCls(a.overItemCls)
  4287. }
  4288. },
  4289. shouldUpdateCell : function() {
  4290. return true
  4291. }
  4292. }
  4293. },
  4294. hasRightColumns : function() {
  4295. return this.headerCt.items.getCount() > 1
  4296. },
  4297. checkHorizontalFit : function() {
  4298. if (this.orientation === "horizontal") {
  4299. var a = this.getActualTimeColumnWidth();
  4300. var c = this.getFittingColumnWidth();
  4301. if (this.forceFit) {
  4302. if (c != a) {
  4303. this.fitColumns()
  4304. }
  4305. } else {
  4306. if (this.snapToIncrement) {
  4307. var b = this.calculateTimeColumnWidth(a);
  4308. if (b > 0 && b !== a) {
  4309. this.setColumnWidth(b)
  4310. }
  4311. } else {
  4312. if (a < c) {
  4313. this.fitColumns()
  4314. }
  4315. }
  4316. }
  4317. }
  4318. },
  4319. getTimeAxisColumn : function() {
  4320. return this.headerCt.items.get(0)
  4321. },
  4322. getFirstTimeColumn : function() {
  4323. return this.headerCt.getGridColumns()[0]
  4324. },
  4325. getFormattedDate : function(a) {
  4326. return Ext.Date.format(a, this.getDisplayDateFormat())
  4327. },
  4328. getFormattedEndDate : function(d, a) {
  4329. var b = this.timeAxis, c = b.getResolution().unit;
  4330. if (c in this.largeUnits
  4331. && d.getHours() === 0
  4332. && d.getMinutes() === 0
  4333. && !(d.getYear() === a.getYear()
  4334. && d.getMonth() === a.getMonth() && d.getDate() === a
  4335. .getDate())) {
  4336. d = Sch.util.Date.add(d, Sch.util.Date.DAY, -1)
  4337. }
  4338. return Ext.Date.format(d, this.getDisplayDateFormat())
  4339. },
  4340. getDisplayDateFormat : function() {
  4341. return this.displayDateFormat
  4342. },
  4343. setDisplayDateFormat : function(a) {
  4344. this.displayDateFormat = a
  4345. },
  4346. getSingleUnitInPixels : function(a) {
  4347. return Sch.util.Date.getUnitToBaseUnitRatio(this.timeAxis.getUnit(), a)
  4348. * this.getSingleTickInPixels() / this.timeAxis.getIncrement()
  4349. },
  4350. getSingleTickInPixels : function() {
  4351. throw "Must be implemented by horizontal/vertical"
  4352. },
  4353. scrollEventIntoView : function(f, c, a, j, k) {
  4354. k = k || this;
  4355. var h = this;
  4356. var d = this.panel._top.store;
  4357. var i = function(l) {
  4358. l.scrollIntoView(h.el, true, a);
  4359. if (c) {
  4360. if (typeof c === "boolean") {
  4361. l.highlight()
  4362. } else {
  4363. l.highlight(null, c)
  4364. }
  4365. }
  4366. j && j.call(k)
  4367. };
  4368. var e = Ext.data && Ext.data.TreeStore
  4369. && d instanceof Ext.data.TreeStore && !f.isVisible();
  4370. if (e) {
  4371. f.bubble(function(l) {
  4372. l.expand()
  4373. })
  4374. }
  4375. var b = this.getOuterElementFromEventRecord(f);
  4376. if (b) {
  4377. i(b)
  4378. } else {
  4379. var g = this.panel.verticalScroller;
  4380. if (d.buffered && g) {
  4381. Ext.Function.defer(function() {
  4382. g.scrollTo(d.getIndexInTotalDataset(f), false,
  4383. function() {
  4384. var l = h
  4385. .getOuterElementFromEventRecord(f);
  4386. if (l) {
  4387. i(l)
  4388. }
  4389. })
  4390. }, e ? 10 : 0)
  4391. }
  4392. }
  4393. },
  4394. calculateTimeColumnWidth : function(e) {
  4395. if (!this.panel.rendered) {
  4396. return e
  4397. }
  4398. var h = this.forceFit;
  4399. var b = 0, d = this.timeAxis.getUnit(), k = this.timeAxis.getCount(), g = Number.MAX_VALUE;
  4400. if (this.snapToIncrement) {
  4401. var i = this.timeAxis.getResolution(), j = i.unit, c = i.increment;
  4402. g = Sch.util.Date.getUnitToBaseUnitRatio(d, j) * c
  4403. }
  4404. var f = Sch.util.Date.getMeasuringUnit(d);
  4405. g = Math.min(g, Sch.util.Date.getUnitToBaseUnitRatio(d, f));
  4406. var a = Math.floor(this.getAvailableWidthForSchedule() / k);
  4407. b = (h || e < a) ? a : e;
  4408. if (g > 0 && (!h || g < 1)) {
  4409. b = Math.round(Math.max(1, Math[h ? "floor" : "round"](g * b)) / g)
  4410. }
  4411. return b
  4412. },
  4413. getFittingColumnWidth : function() {
  4414. var a = Math.floor(this.getAvailableWidthForSchedule()
  4415. / this.timeAxis.getCount());
  4416. return this.calculateTimeColumnWidth(a)
  4417. },
  4418. fitColumns : function(b) {
  4419. var a = 0;
  4420. if (this.orientation === "horizontal") {
  4421. a = this.getFittingColumnWidth()
  4422. } else {
  4423. a = Math.floor((this.panel.getWidth()
  4424. - Ext.getScrollbarSize().width - 1)
  4425. / this.headerCt.getColumnCount())
  4426. }
  4427. this.setColumnWidth(a, b)
  4428. },
  4429. getAvailableWidthForSchedule : function() {
  4430. var c = (this.lastBox && this.lastBox.width) || this.getWidth();
  4431. var a = this.headerCt.items.items;
  4432. for (var b = 1; b < a.length; b++) {
  4433. c -= a[b].getWidth()
  4434. }
  4435. return c - Ext.getScrollbarSize().width - 1
  4436. },
  4437. getRightColumnsWidth : function() {
  4438. var c = 0;
  4439. var a = this.headerCt.items.items;
  4440. for (var b = 1; b < a.length; b++) {
  4441. c += a[b].getWidth()
  4442. }
  4443. return c
  4444. },
  4445. fixRightColumnsPositions : function() {
  4446. var a = this.headerCt.items.items;
  4447. var c = a[0].getWidth();
  4448. for (var b = 1; b < a.length; b++) {
  4449. var d = a[b];
  4450. d.el.setLeft(c);
  4451. c += d.getWidth()
  4452. }
  4453. },
  4454. getElementFromEventRecord : function(a) {
  4455. return Ext.get(this.eventPrefix + a.internalId)
  4456. },
  4457. getEventNodeByRecord : function(a) {
  4458. return document.getElementById(this.eventPrefix + a.internalId)
  4459. },
  4460. getOuterElementFromEventRecord : function(a) {
  4461. return Ext.get(this.eventPrefix + a.internalId)
  4462. },
  4463. resolveColumnIndex : function(a) {
  4464. return Math.floor(a / this.getActualTimeColumnWidth())
  4465. },
  4466. getStartEndDatesFromRegion : function(b, a) {
  4467. throw "Must be implemented by horizontal/vertical"
  4468. },
  4469. setupTooltip : function() {
  4470. var b = this, a = Ext.apply({
  4471. renderTo : Ext.getBody(),
  4472. delegate : b.eventSelector,
  4473. target : b.el,
  4474. anchor : "b"
  4475. }, b.tipCfg);
  4476. b.tip = Ext.create("Ext.ToolTip", a);
  4477. b.tip.on({
  4478. beforeshow : function(d) {
  4479. if (!d.triggerElement || !d.triggerElement.id) {
  4480. return false
  4481. }
  4482. var c = this.resolveEventRecord(d.triggerElement);
  4483. if (!c
  4484. || this.fireEvent("beforetooltipshow", this, c) === false) {
  4485. return false
  4486. }
  4487. d.update(this.tooltipTpl.apply(this.getDataForTooltipTpl(c)));
  4488. return true
  4489. },
  4490. scope : this
  4491. })
  4492. },
  4493. getDataForTooltipTpl : function(a) {
  4494. return a.data
  4495. },
  4496. getTimeResolution : function() {
  4497. return this.timeAxis.getResolution()
  4498. },
  4499. setTimeResolution : function(b, a) {
  4500. this.timeAxis.setResolution(b, a);
  4501. if (this.snapToIncrement) {
  4502. this.refreshKeepingScroll()
  4503. }
  4504. },
  4505. getEventIdFromDomNodeId : function(a) {
  4506. return a.substring(this.eventPrefix.length)
  4507. },
  4508. getDateFromDomEvent : function(b, a) {
  4509. return this.getDateFromXY(b.getXY(), a)
  4510. },
  4511. handleScheduleEvent : function(c) {
  4512. var b = c.getTarget("." + this.timeCellCls, 2);
  4513. if (b) {
  4514. var a = this.getDateFromDomEvent(c, "floor");
  4515. this.fireEvent("schedule" + c.type, this, a, this.indexOf(this
  4516. .findItemByChild(b)), c)
  4517. }
  4518. },
  4519. setupTimeCellEvents : function() {
  4520. this.mon(this.el, {
  4521. click : this.handleScheduleEvent,
  4522. dblclick : this.handleScheduleEvent,
  4523. contextmenu : this.handleScheduleEvent,
  4524. scope : this
  4525. }, this)
  4526. },
  4527. getSnapPixelAmount : function() {
  4528. if (this.snapToIncrement) {
  4529. var a = this.timeAxis.getResolution();
  4530. return (a.increment || 1) * this.getSingleUnitInPixels(a.unit)
  4531. } else {
  4532. return 1
  4533. }
  4534. },
  4535. getActualTimeColumnWidth : function() {
  4536. return this.headerCt.items.get(0).getTimeColumnWidth()
  4537. },
  4538. setSnapEnabled : function(a) {
  4539. this.snapToIncrement = a;
  4540. if (a) {
  4541. this.refreshKeepingScroll()
  4542. }
  4543. },
  4544. setReadOnly : function(a) {
  4545. this.readOnly = a;
  4546. this[a ? "addCls" : "removeCls"](this._cmpCls + "-readonly")
  4547. },
  4548. isReadOnly : function() {
  4549. return this.readOnly
  4550. },
  4551. setOrientation : function(a) {
  4552. this.orientation = a;
  4553. Ext.apply(this, Sch.view[Ext.String.capitalize(a)].prototype.props)
  4554. },
  4555. getOrientation : function() {
  4556. return this.orientation
  4557. },
  4558. translateToScheduleCoordinate : function(a) {
  4559. throw "Abstract method call!"
  4560. },
  4561. translateToPageCoordinate : function(a) {
  4562. throw "Abstract method call!"
  4563. },
  4564. getDateFromXY : function(c, b, a) {
  4565. throw "Abstract method call!"
  4566. },
  4567. getXYFromDate : function(a, b) {
  4568. throw "Abstract method call!"
  4569. },
  4570. getTimeSpanRegion : function(a, b) {
  4571. throw "Abstract method call!"
  4572. },
  4573. getStart : function() {
  4574. return this.timeAxis.getStart()
  4575. },
  4576. getEnd : function() {
  4577. return this.timeAxis.getEnd()
  4578. },
  4579. setBarMargin : function(b, a) {
  4580. this.barMargin = b;
  4581. if (!a) {
  4582. this.refreshKeepingScroll()
  4583. }
  4584. },
  4585. setRowHeight : function(a, b) {
  4586. this.rowHeight = a || 24;
  4587. if (this.rendered && !b) {
  4588. this.refreshKeepingScroll()
  4589. }
  4590. },
  4591. refreshKeepingScroll : function(a) {
  4592. this.saveScrollState();
  4593. if (this.lightRefresh) {
  4594. this.lightRefresh()
  4595. } else {
  4596. this.refresh()
  4597. }
  4598. this.restoreScrollState()
  4599. },
  4600. refreshKeepingResourceScroll : function(c) {
  4601. var d = this.el.dom, b = d.scrollTop, a = d.scrollLeft;
  4602. if (this.lightRefresh) {
  4603. this.lightRefresh()
  4604. } else {
  4605. this.refresh()
  4606. }
  4607. if (this.getOrientation() === "horizontal") {
  4608. d.scrollTop = b
  4609. } else {
  4610. d.scrollLeft = a
  4611. }
  4612. },
  4613. lightRefresh : function() {
  4614. var a = this.refreshSize;
  4615. Ext.suspendLayouts();
  4616. this.refreshSize = Ext.emptyFn;
  4617. this.__lightRefresh = true;
  4618. this.refresh();
  4619. delete this.__lightRefresh;
  4620. this.refreshSize = a;
  4621. Ext.resumeLayouts()
  4622. }
  4623. }, function() {
  4624. Ext.apply(Sch, {
  4625. VERSION : "2.1.11"
  4626. })
  4627. });
  4628. Ext.define("Sch.view.Horizontal", {
  4629. props : {
  4630. translateToScheduleCoordinate : function(a) {
  4631. return a - this.el.getX() + this.el.getScroll().left
  4632. },
  4633. translateToPageCoordinate : function(a) {
  4634. return a + this.el.getX() - this.el.getScroll().left
  4635. },
  4636. getDateFromXY : function(h, f, e) {
  4637. var b, a = e ? h[0] : this.translateToScheduleCoordinate(h[0]), d = a
  4638. / this.getActualTimeColumnWidth(), c = this.timeAxis
  4639. .getCount();
  4640. if (d < 0 || d > c) {
  4641. b = null
  4642. } else {
  4643. var g = d - this.resolveColumnIndex(a);
  4644. if (g > 2 && d >= c) {
  4645. return null
  4646. }
  4647. b = this.timeAxis.getDateFromTick(d, f)
  4648. }
  4649. return b
  4650. },
  4651. getXYFromDate : function(b, d) {
  4652. var a, c = this.timeAxis.getTickFromDate(b);
  4653. if (c >= 0) {
  4654. a = this.getActualTimeColumnWidth() * c
  4655. }
  4656. if (d === false) {
  4657. a = this.translateToPageCoordinate(a)
  4658. }
  4659. return [Math.round(a), 0]
  4660. },
  4661. getEventBox : function(e, b) {
  4662. var a = Math.floor(this.getXYFromDate(e)[0]), c = Math.floor(this
  4663. .getXYFromDate(b)[0]), d = Math;
  4664. if (this.managedEventSizing) {
  4665. return {
  4666. top : Math.max(0, (this.barMargin
  4667. - (Ext.isIE && !Ext.isStrict)
  4668. ? 0
  4669. : this.eventBorderWidth
  4670. - this.cellBorderWidth)),
  4671. left : d.min(a, c),
  4672. width : d.max(1, d.abs(a - c) - this.eventBorderWidth),
  4673. height : this.rowHeight - (2 * this.barMargin)
  4674. - this.eventBorderWidth
  4675. }
  4676. }
  4677. return {
  4678. left : d.min(a, c),
  4679. width : d.max(1, d.abs(a - c))
  4680. }
  4681. },
  4682. layoutEvents : function(a) {
  4683. var c = Ext.Array.clone(a);
  4684. c.sort(this.sortEvents);
  4685. var b = this.layoutEventsInBands(0, c);
  4686. return b
  4687. },
  4688. layoutEventsInBands : function(d, a) {
  4689. var c = a[0], b = d === 0
  4690. ? this.barMargin
  4691. : (d * this.rowHeight - ((d - 1) * this.barMargin));
  4692. if (b >= this.cellBorderWidth) {
  4693. b -= this.cellBorderWidth
  4694. }
  4695. while (c) {
  4696. c.top = b;
  4697. Ext.Array.remove(a, c);
  4698. c = this.findClosestSuccessor(c, a)
  4699. }
  4700. d++;
  4701. if (a.length > 0) {
  4702. return this.layoutEventsInBands(d, a)
  4703. } else {
  4704. return d
  4705. }
  4706. },
  4707. getScheduleRegion : function(d, f) {
  4708. var h = d ? Ext.fly(this.getNodeByRecord(d)).getRegion() : this.el
  4709. .down(".x-grid-table").getRegion(), e = this.timeAxis
  4710. .getStart(), j = this.timeAxis.getEnd(), b = this
  4711. .getDateConstraints(d, f)
  4712. || {
  4713. start : e,
  4714. end : j
  4715. }, c = this.translateToPageCoordinate(this
  4716. .getXYFromDate(b.start)[0]), i = this
  4717. .translateToPageCoordinate(this.getXYFromDate(b.end)[0])
  4718. - this.eventBorderWidth, g = h.top + this.barMargin, a = h.bottom
  4719. - this.barMargin - this.eventBorderWidth;
  4720. return new Ext.util.Region(g, Math.max(c, i), a, Math.min(c, i))
  4721. },
  4722. getResourceRegion : function(h, d, g) {
  4723. var k = Ext.fly(this.getNodeByRecord(h)).getRegion(), i = this.timeAxis
  4724. .getStart(), n = this.timeAxis.getEnd(), c = d
  4725. ? Sch.util.Date.max(i, d)
  4726. : i, e = g ? Sch.util.Date.min(n, g) : n, f = this
  4727. .getXYFromDate(c)[0], m = this.getXYFromDate(e)[0]
  4728. - this.eventBorderWidth, l = this.el.getTop(), b = this.el
  4729. .getScroll(), j = k.top + 1 - l + b.top, a = k.bottom - 1
  4730. - l + b.top;
  4731. return new Ext.util.Region(j, Math.max(f, m), a, Math.min(f, m))
  4732. },
  4733. collectRowData : function(g, p, o) {
  4734. var c = this.eventStore.getEventsForResource(p);
  4735. if (c.length === 0 || this.headerCt.getColumnCount() === 0) {
  4736. g.rowHeight = this.rowHeight;
  4737. return g
  4738. }
  4739. var a = Sch.util.Date, m = this.timeAxis, n = m.getStart(), r = m
  4740. .getEnd(), k = [], j, f;
  4741. for (j = 0, f = c.length; j < f; j++) {
  4742. var b = c[j], d = b.getStartDate(), h = b.getEndDate();
  4743. if (d && h && m.timeSpanInAxis(d, h)) {
  4744. var q = this.generateTplData(b, n, r, p, o);
  4745. k[k.length] = q
  4746. }
  4747. }
  4748. var e = 1;
  4749. if (this.dynamicRowHeight) {
  4750. e = this.layoutEvents(k)
  4751. }
  4752. g.rowHeight = (e * this.rowHeight) - ((e - 1) * this.barMargin);
  4753. g[this.getFirstTimeColumn().id] += "&#160;"
  4754. + this.eventTpl.apply(k);
  4755. return g
  4756. },
  4757. resolveResource : function(a) {
  4758. var b = this.findItemByChild(a);
  4759. if (b) {
  4760. return this.getRecord(b)
  4761. }
  4762. return null
  4763. },
  4764. getTimeSpanRegion : function(b, h, g) {
  4765. var d = this.getXYFromDate(b)[0], f = this.getXYFromDate(h || b)[0], a, c;
  4766. if (this.store.buffered) {
  4767. var e;
  4768. if (this.panel.verticalScroller.stretcher instanceof Ext.CompositeElement) {
  4769. e = this.panel.verticalScroller.stretcher.first()
  4770. } else {
  4771. e = this.el.down(".x-stretcher")
  4772. }
  4773. if (e.dom.clientHeight) {
  4774. c = e
  4775. }
  4776. }
  4777. if (!c) {
  4778. c = this.el.down(".x-grid-table")
  4779. }
  4780. if (g) {
  4781. a = Math.max(c ? c.dom.clientHeight : 0,
  4782. this.el.dom.clientHeight)
  4783. } else {
  4784. a = c ? c.dom.clientHeight : 0
  4785. }
  4786. return new Ext.util.Region(0, Math.max(d, f), a, Math.min(d, f))
  4787. },
  4788. getStartEndDatesFromRegion : function(c, b) {
  4789. var a = this.getDateFromXY([c.left, 0], b), d = this.getDateFromXY(
  4790. [c.right, 0], b);
  4791. if (d && a) {
  4792. return {
  4793. start : Sch.util.Date.min(a, d),
  4794. end : Sch.util.Date.max(a, d)
  4795. }
  4796. } else {
  4797. return null
  4798. }
  4799. },
  4800. onEventAdd : function(m, h) {
  4801. var e = {};
  4802. for (var g = 0, c = h.length; g < c; g++) {
  4803. var a = h[g].getResources();
  4804. for (var f = 0, d = a.length; f < d; f++) {
  4805. var b = a[f];
  4806. e[b.getId()] = b
  4807. }
  4808. }
  4809. Ext.Object.each(e, function(j, i) {
  4810. this.onUpdate(this.resourceStore, i)
  4811. }, this)
  4812. },
  4813. onEventRemove : function(e, b) {
  4814. var h = b.getResources();
  4815. var f = this.resourceStore;
  4816. var a = Ext.tree.View && this instanceof Ext.tree.View;
  4817. var d = function(i) {
  4818. if (a && this.store.indexOf(i)) {
  4819. this.onUpdate(this.store, i)
  4820. } else {
  4821. if (f.indexOf(i) >= 0) {
  4822. this.onUpdate(f, i)
  4823. }
  4824. }
  4825. };
  4826. if (h.length > 1) {
  4827. Ext.each(h, d, this)
  4828. } else {
  4829. var c = this.getElementFromEventRecord(b);
  4830. if (c) {
  4831. var g = this.resolveResource(c);
  4832. c.fadeOut({
  4833. callback : function() {
  4834. d.call(this, g)
  4835. },
  4836. scope : this
  4837. })
  4838. }
  4839. }
  4840. },
  4841. onEventUpdate : function(b, c, a) {
  4842. var d = c.previous;
  4843. if (d && d[c.resourceIdField]) {
  4844. var e = c.getResource(d[c.resourceIdField]);
  4845. if (e) {
  4846. this.onUpdate(this.resourceStore, e)
  4847. }
  4848. }
  4849. var f = c.getResources();
  4850. Ext.each(f, function(g) {
  4851. this.onUpdate(this.resourceStore, g)
  4852. }, this)
  4853. },
  4854. getSingleTickInPixels : function() {
  4855. return this.getActualTimeColumnWidth()
  4856. },
  4857. getColumnWidth : function() {
  4858. if (this.getTimeAxisColumn()) {
  4859. return this.getTimeAxisColumn().getTimeColumnWidth()
  4860. }
  4861. },
  4862. setColumnWidth : function(b, a) {
  4863. if (this.getTimeAxisColumn()) {
  4864. this.getTimeAxisColumn().setTimeColumnWidth(b);
  4865. if (!a) {
  4866. this.refreshKeepingScroll()
  4867. }
  4868. }
  4869. this.fireEvent("columnwidthchange", this, b)
  4870. },
  4871. getVisibleDateRange : function() {
  4872. if (!this.rendered) {
  4873. return null
  4874. }
  4875. var c = this.getEl().getScroll(), b = this.panel.getStart(), f = this.panel
  4876. .getEnd(), e = this.getWidth(), d = this.getEl()
  4877. .down(".x-grid-table").dom, a = d.clientWidth;
  4878. if (a < e) {
  4879. return {
  4880. startDate : b,
  4881. endDate : f
  4882. }
  4883. }
  4884. return {
  4885. startDate : this.getDateFromXY([c.left, 0], null, true),
  4886. endDate : this.getDateFromXY([Math.min(c.left + e, a), 0],
  4887. null, true)
  4888. }
  4889. }
  4890. }
  4891. });
  4892. Ext.define("Sch.mixin.FilterableTreeView", {
  4893. initTreeFiltering : function() {
  4894. var a = function() {
  4895. var b = this.up("tablepanel").store;
  4896. this.mon(b, "nodestore-datachange-start",
  4897. this.onFilterChangeStart, this);
  4898. this.mon(b, "nodestore-datachange-end",
  4899. this.onFilterChangeEnd, this);
  4900. this.mon(b, "filter-clear", this.onFilterCleared, this);
  4901. this.mon(b, "filter-set", this.onFilterSet, this)
  4902. };
  4903. if (this.rendered) {
  4904. a.call(this)
  4905. } else {
  4906. this.on("beforerender", a, this, {
  4907. single : true
  4908. })
  4909. }
  4910. },
  4911. onFilterChangeStart : function() {
  4912. Ext.suspendLayouts()
  4913. },
  4914. onFilterChangeEnd : function() {
  4915. Ext.resumeLayouts()
  4916. },
  4917. onFilterCleared : function() {
  4918. delete this.toggle;
  4919. var a = this.getEl();
  4920. if (a) {
  4921. a.removeCls("sch-tree-filtered")
  4922. }
  4923. },
  4924. onFilterSet : function() {
  4925. this.toggle = function() {
  4926. };
  4927. var a = this.getEl();
  4928. if (a) {
  4929. a.addCls("sch-tree-filtered")
  4930. }
  4931. }
  4932. });
  4933. Ext.define("Sch.view.TimelineTreeView", {
  4934. extend : "Ext.tree.View",
  4935. mixins : ["Sch.mixin.TimelineView", "Sch.mixin.FilterableTreeView"],
  4936. requires : ["Sch.patches.TreeView"],
  4937. cellBorderWidth : 0,
  4938. constructor : function() {
  4939. this.callParent(arguments);
  4940. this.initTreeFiltering()
  4941. }
  4942. }, function() {
  4943. this
  4944. .override(Sch.mixin.TimelineView.prototype.inheritables()
  4945. || {})
  4946. });
  4947. Ext.define("Sch.mixin.Zoomable", {
  4948. zoomLevels : [{
  4949. width : 30,
  4950. increment : 1,
  4951. resolution : 1,
  4952. preset : "year",
  4953. resolutionUnit : "MONTH"
  4954. }, {
  4955. width : 50,
  4956. increment : 1,
  4957. resolution : 1,
  4958. preset : "year",
  4959. resolutionUnit : "MONTH"
  4960. }, {
  4961. width : 100,
  4962. increment : 1,
  4963. resolution : 1,
  4964. preset : "year",
  4965. resolutionUnit : "MONTH"
  4966. }, {
  4967. width : 200,
  4968. increment : 1,
  4969. resolution : 1,
  4970. preset : "year",
  4971. resolutionUnit : "MONTH"
  4972. }, {
  4973. width : 100,
  4974. increment : 1,
  4975. resolution : 7,
  4976. preset : "monthAndYear",
  4977. resolutionUnit : "DAY"
  4978. }, {
  4979. width : 30,
  4980. increment : 1,
  4981. resolution : 1,
  4982. preset : "weekDateAndMonth",
  4983. resolutionUnit : "DAY"
  4984. }, {
  4985. width : 35,
  4986. increment : 1,
  4987. resolution : 1,
  4988. preset : "weekAndMonth",
  4989. resolutionUnit : "DAY"
  4990. }, {
  4991. width : 50,
  4992. increment : 1,
  4993. resolution : 1,
  4994. preset : "weekAndMonth",
  4995. resolutionUnit : "DAY"
  4996. }, {
  4997. width : 20,
  4998. increment : 1,
  4999. resolution : 1,
  5000. preset : "weekAndDayLetter"
  5001. }, {
  5002. width : 50,
  5003. increment : 1,
  5004. resolution : 1,
  5005. preset : "weekAndDay",
  5006. resolutionUnit : "HOUR"
  5007. }, {
  5008. width : 100,
  5009. increment : 1,
  5010. resolution : 1,
  5011. preset : "weekAndDay",
  5012. resolutionUnit : "HOUR"
  5013. }, {
  5014. width : 50,
  5015. increment : 6,
  5016. resolution : 30,
  5017. preset : "hourAndDay",
  5018. resolutionUnit : "MINUTE"
  5019. }, {
  5020. width : 100,
  5021. increment : 6,
  5022. resolution : 30,
  5023. preset : "hourAndDay",
  5024. resolutionUnit : "MINUTE"
  5025. }, {
  5026. width : 60,
  5027. increment : 2,
  5028. resolution : 30,
  5029. preset : "hourAndDay",
  5030. resolutionUnit : "MINUTE"
  5031. }, {
  5032. width : 60,
  5033. increment : 1,
  5034. resolution : 30,
  5035. preset : "hourAndDay",
  5036. resolutionUnit : "MINUTE"
  5037. }, {
  5038. width : 30,
  5039. increment : 15,
  5040. resolution : 5,
  5041. preset : "minuteAndHour"
  5042. }, {
  5043. width : 60,
  5044. increment : 15,
  5045. resolution : 5,
  5046. preset : "minuteAndHour"
  5047. }, {
  5048. width : 130,
  5049. increment : 15,
  5050. resolution : 5,
  5051. preset : "minuteAndHour"
  5052. }, {
  5053. width : 60,
  5054. increment : 5,
  5055. resolution : 5,
  5056. preset : "minuteAndHour"
  5057. }, {
  5058. width : 100,
  5059. increment : 5,
  5060. resolution : 5,
  5061. preset : "minuteAndHour"
  5062. }],
  5063. minZoomLevel : null,
  5064. maxZoomLevel : null,
  5065. visibleZoomFactor : 5,
  5066. cachedCenterDate : null,
  5067. isFirstZoom : true,
  5068. isZooming : false,
  5069. initializeZooming : function() {
  5070. this.zoomLevels = this.zoomLevels.slice();
  5071. this.setMinZoomLevel(this.minZoomLevel || 0);
  5072. this.setMaxZoomLevel(this.maxZoomLevel !== null
  5073. ? this.maxZoomLevel
  5074. : this.zoomLevels.length - 1);
  5075. this.on("viewchange", this.clearCenterDateCache, this)
  5076. },
  5077. getZoomLevelUnit : function(b) {
  5078. var a = Sch.preset.Manager.getPreset(b.preset).headerConfig;
  5079. return a.bottom ? a.bottom.unit : a.middle.unit
  5080. },
  5081. getMilliSecondsPerPixelForZoomLevel : function(b) {
  5082. var a = Sch.util.Date;
  5083. return Math.round((a.add(new Date(1, 0, 1), this.getZoomLevelUnit(b),
  5084. b.increment) - new Date(1, 0, 1))
  5085. / b.width)
  5086. },
  5087. presetToZoomLevel : function(e) {
  5088. var d = Sch.preset.Manager.getPreset(e);
  5089. var c = d.headerConfig;
  5090. var a = c.bottom;
  5091. var b = c.middle;
  5092. return {
  5093. preset : e,
  5094. increment : (a ? a.increment : b.increment) || 1,
  5095. resolution : d.timeResolution.increment,
  5096. resolutionUnit : d.timeResolution.unit,
  5097. width : d.timeColumnWidth
  5098. }
  5099. },
  5100. calculateCurrentZoomLevel : function() {
  5101. var d = this.presetToZoomLevel(this.viewPreset);
  5102. var c = this.timeAxis.headerConfig;
  5103. var a = c.bottom;
  5104. var b = c.middle;
  5105. d.width = this.timeAxis.preset.timeColumnWidth;
  5106. d.increment = (a ? a.increment : b.increment) || 1;
  5107. return d
  5108. },
  5109. getCurrentZoomLevelIndex : function() {
  5110. var f = this.calculateCurrentZoomLevel();
  5111. var b = this.getMilliSecondsPerPixelForZoomLevel(f);
  5112. var e = this.zoomLevels;
  5113. for (var c = 0; c < e.length; c++) {
  5114. var d = this.getMilliSecondsPerPixelForZoomLevel(e[c]);
  5115. if (d == b) {
  5116. return c
  5117. }
  5118. if (c === 0 && b > d) {
  5119. return -0.5
  5120. }
  5121. if (c == e.length - 1 && b < d) {
  5122. return e.length - 1 + 0.5
  5123. }
  5124. var a = this.getMilliSecondsPerPixelForZoomLevel(e[c + 1]);
  5125. if (d > b && b > a) {
  5126. return c + 0.5
  5127. }
  5128. }
  5129. throw "Can't find current zoom level index"
  5130. },
  5131. setMaxZoomLevel : function(a) {
  5132. if (a < 0 || a >= this.zoomLevels.length) {
  5133. throw new Error("Invalid range for `setMinZoomLevel`")
  5134. }
  5135. this.maxZoomLevel = a
  5136. },
  5137. setMinZoomLevel : function(a) {
  5138. if (a < 0 || a >= this.zoomLevels.length) {
  5139. throw new Error("Invalid range for `setMinZoomLevel`")
  5140. }
  5141. this.minZoomLevel = a
  5142. },
  5143. getViewportCenterDateCached : function() {
  5144. if (this.cachedCenterDate) {
  5145. return this.cachedCenterDate
  5146. }
  5147. return this.cachedCenterDate = this.getViewportCenterDate()
  5148. },
  5149. clearCenterDateCache : function() {
  5150. this.cachedCenterDate = null
  5151. },
  5152. zoomToLevel : function(b) {
  5153. b = Ext.Number.constrain(b, this.minZoomLevel, this.maxZoomLevel);
  5154. var n = this.calculateCurrentZoomLevel();
  5155. var d = this.getMilliSecondsPerPixelForZoomLevel(n);
  5156. var i = this.zoomLevels[b];
  5157. var a = this.getMilliSecondsPerPixelForZoomLevel(i);
  5158. if (d == a) {
  5159. return null
  5160. }
  5161. var p = this;
  5162. var j = this.getSchedulingView();
  5163. var f = j.getEl();
  5164. if (this.isFirstZoom) {
  5165. this.isFirstZoom = false;
  5166. f.on("scroll", this.clearCenterDateCache, this)
  5167. }
  5168. var h = this.orientation == "vertical";
  5169. var e = this.getViewportCenterDateCached();
  5170. var k = h ? f.getHeight() : f.getWidth();
  5171. var l = Ext.clone(Sch.preset.Manager.getPreset(i.preset));
  5172. var o = this.calculateOptimalDateRange(e, k, i);
  5173. var c = l.headerConfig;
  5174. var g = c.bottom;
  5175. var r = c.middle;
  5176. l[h ? "rowHeight" : "timeColumnWidth"] = i.width;
  5177. if (g) {
  5178. g.increment = i.increment
  5179. } else {
  5180. r.increment = i.increment
  5181. }
  5182. this.isZooming = true;
  5183. this.viewPreset = i.preset;
  5184. var m = g ? g.unit : r.unit;
  5185. this.timeAxis.reconfigure({
  5186. preset : l,
  5187. headerConfig : c,
  5188. unit : m,
  5189. increment : i.increment,
  5190. resolutionUnit : Sch.util.Date.getUnitByName(i.resolutionUnit || m),
  5191. resolutionIncrement : i.resolution,
  5192. weekStartDay : this.weekStartDay,
  5193. mainUnit : r.unit,
  5194. shiftUnit : l.shiftUnit,
  5195. shiftIncrement : l.shiftIncrement || 1,
  5196. defaultSpan : l.defaultSpan || 1,
  5197. start : o.startDate || this.getStart(),
  5198. end : o.endDate || this.getEnd()
  5199. });
  5200. var q = j.getXYFromDate(e, true);
  5201. f.on("scroll", function() {
  5202. p.cachedCenterDate = e
  5203. }, this, {
  5204. single : true
  5205. });
  5206. if (h) {
  5207. f.scrollTo("top", q[1] - k / 2)
  5208. } else {
  5209. f.scrollTo("left", q[0] - k / 2)
  5210. }
  5211. p.isZooming = false;
  5212. this.fireEvent("zoomchange", this, b);
  5213. return b
  5214. },
  5215. zoomIn : function(a) {
  5216. a = a || 1;
  5217. var b = this.getCurrentZoomLevelIndex();
  5218. if (b >= this.zoomLevels.length - 1) {
  5219. return null
  5220. }
  5221. return this.zoomToLevel(Math.floor(b) + a)
  5222. },
  5223. zoomOut : function(a) {
  5224. a = a || 1;
  5225. var b = this.getCurrentZoomLevelIndex();
  5226. if (b <= 0) {
  5227. return null
  5228. }
  5229. return this.zoomToLevel(Math.ceil(b) - a)
  5230. },
  5231. zoomInFull : function() {
  5232. return this.zoomToLevel(this.maxZoomLevel)
  5233. },
  5234. zoomOutFull : function() {
  5235. return this.zoomToLevel(this.minZoomLevel)
  5236. },
  5237. calculateOptimalDateRange : function(c, h, e) {
  5238. var b = Sch.util.Date;
  5239. var i = Sch.preset.Manager.getPreset(e.preset).headerConfig;
  5240. var f = i.top ? i.top.unit : i.middle.unit;
  5241. var j = this.getZoomLevelUnit(e);
  5242. var d = Math.ceil(h / e.width * e.increment * this.visibleZoomFactor
  5243. / 2);
  5244. var a = b.add(c, j, -d);
  5245. var g = b.add(c, j, d);
  5246. return {
  5247. startDate : this.timeAxis.floorDate(a, false, f),
  5248. endDate : this.timeAxis.ceilDate(g, false, f)
  5249. }
  5250. }
  5251. });
  5252. Ext.define("Sch.mixin.TimelinePanel", {
  5253. requires : ["Sch.util.Patch", "Sch.patches.LoadMask", "Sch.patches.Model",
  5254. "Sch.patches.Table", "Sch.data.TimeAxis",
  5255. "Sch.feature.ColumnLines", "Sch.view.Locking",
  5256. "Sch.mixin.Lockable", "Sch.preset.Manager"],
  5257. mixins : ["Sch.mixin.Zoomable"],
  5258. orientation : "horizontal",
  5259. weekStartDay : 1,
  5260. snapToIncrement : false,
  5261. readOnly : false,
  5262. eventResizeHandles : "both",
  5263. viewPreset : "weekAndDay",
  5264. trackHeaderOver : true,
  5265. startDate : null,
  5266. endDate : null,
  5267. eventBorderWidth : 1,
  5268. tooltipTpl : null,
  5269. tipCfg : {
  5270. cls : "sch-tip",
  5271. showDelay : 1000,
  5272. hideDelay : 0,
  5273. autoHide : true,
  5274. anchor : "b"
  5275. },
  5276. lightWeight : true,
  5277. timeCellRenderer : null,
  5278. timeCellRendererScope : null,
  5279. inheritables : function() {
  5280. return {
  5281. columnLines : true,
  5282. enableColumnMove : false,
  5283. enableLocking : true,
  5284. lockable : true,
  5285. lockedXType : null,
  5286. normalXType : null,
  5287. initComponent : function() {
  5288. this.lightWeight = this.lightWeight && !this.timeCellRenderer;
  5289. this.addEvents("timeheaderdblclick", "beforeviewchange",
  5290. "viewchange");
  5291. if (!this.timeAxis) {
  5292. this.timeAxis = Ext.create("Sch.data.TimeAxis")
  5293. }
  5294. if (!this.columns && !this.colModel) {
  5295. this.columns = []
  5296. }
  5297. this.timeAxis.on("reconfigure", this.onTimeAxisReconfigure,
  5298. this);
  5299. if (this.enableLocking) {
  5300. this.self.mixin("lockable", Sch.mixin.Lockable);
  5301. var b = 0, a = this.columns.length, c;
  5302. for (; b < a; ++b) {
  5303. c = this.columns[b];
  5304. if (c.locked !== false) {
  5305. c.locked = true
  5306. }
  5307. c.lockable = false
  5308. }
  5309. this.switchViewPreset(this.viewPreset, this.startDate
  5310. || this.timeAxis.getStart(), this.endDate
  5311. || this.timeAxis.getEnd(), true)
  5312. }
  5313. this.callParent(arguments);
  5314. if (this.lockable) {
  5315. this.applyViewSettings(this.timeAxis.preset);
  5316. if (!this.viewPreset) {
  5317. throw "You must define a valid view preset object. See Sch.preset.Manager class for reference"
  5318. }
  5319. if (this.lightWeight && this.columnLines) {
  5320. this.columnLinesFeature = new Sch.feature.ColumnLines();
  5321. this.columnLinesFeature.init(this)
  5322. }
  5323. }
  5324. this.initializeZooming();
  5325. this.relayEvents(this.getView(), ["beforetooltipshow",
  5326. "scheduleclick", "scheduledblclick",
  5327. "schedulecontextmenu"])
  5328. },
  5329. getState : function() {
  5330. var a = this, b = a.callParent(arguments);
  5331. Ext.apply(b, {
  5332. viewPreset : a.viewPreset,
  5333. startDate : a.getStart(),
  5334. endDate : a.getEnd(),
  5335. zoomMinLevel : a.zoomMinLevel,
  5336. zoomMaxLevel : a.zoomMaxLevel,
  5337. currentZoomLevel : a.currentZoomLevel
  5338. });
  5339. return b
  5340. },
  5341. getOrientation : function() {
  5342. return this.orientation
  5343. },
  5344. applyState : function(b) {
  5345. var a = this;
  5346. a.callParent(arguments);
  5347. if (b && b.viewPreset) {
  5348. a.switchViewPreset(b.viewPreset, b.startDate, b.endDate)
  5349. }
  5350. if (b && b.currentZoomLevel) {
  5351. a.zoomToLevel(b.currentZoomLevel)
  5352. }
  5353. },
  5354. beforeRender : function() {
  5355. this.callParent(arguments);
  5356. if (this.lockable) {
  5357. this.addCls("sch-" + this.orientation)
  5358. }
  5359. },
  5360. afterRender : function() {
  5361. this.callParent(arguments);
  5362. if (this.lockable) {
  5363. this.lockedGrid.on("itemdblclick", function(d, c, e, g, f) {
  5364. if (this.orientation == "vertical" && c) {
  5365. this.fireEvent("timeheaderdblclick", this,
  5366. c.get("start"), c.get("end"), g, f)
  5367. }
  5368. }, this)
  5369. } else {
  5370. var b = this.headerCt;
  5371. if (b && b.reorderer && b.reorderer.dropZone) {
  5372. var a = b.reorderer.dropZone;
  5373. a.positionIndicator = Ext.Function.createSequence(
  5374. a.positionIndicator, function() {
  5375. this.valid = false
  5376. })
  5377. }
  5378. }
  5379. },
  5380. delayScroll : function() {
  5381. var a = this.getScrollTarget().el;
  5382. if (a) {
  5383. this.scrollTask.delay(10, function() {
  5384. if (a.dom) {
  5385. this.syncHorizontalScroll(a.dom.scrollLeft)
  5386. }
  5387. }, this)
  5388. }
  5389. }
  5390. }
  5391. },
  5392. setReadOnly : function(a) {
  5393. this.getSchedulingView().setReadOnly(a)
  5394. },
  5395. isReadOnly : function() {
  5396. return this.getSchedulingView().isReadOnly()
  5397. },
  5398. switchViewPreset : function(d, a, f, b) {
  5399. if (this.fireEvent("beforeviewchange", this, d, a, f) !== false) {
  5400. if (Ext.isString(d)) {
  5401. this.viewPreset = d;
  5402. d = Sch.preset.Manager.getPreset(d)
  5403. }
  5404. if (!d) {
  5405. throw "View preset not found"
  5406. }
  5407. var e = d.headerConfig;
  5408. var c = {
  5409. unit : e.bottom ? e.bottom.unit : e.middle.unit,
  5410. increment : (e.bottom ? e.bottom.increment : e.middle.increment)
  5411. || 1,
  5412. resolutionUnit : d.timeResolution.unit,
  5413. resolutionIncrement : d.timeResolution.increment,
  5414. weekStartDay : this.weekStartDay,
  5415. mainUnit : e.middle.unit,
  5416. shiftUnit : d.shiftUnit,
  5417. headerConfig : d.headerConfig,
  5418. shiftIncrement : d.shiftIncrement || 1,
  5419. preset : d,
  5420. defaultSpan : d.defaultSpan || 1
  5421. };
  5422. if (b) {
  5423. if (this.timeAxis.getCount() === 0 || a) {
  5424. c.start = a || new Date();
  5425. c.end = f
  5426. }
  5427. } else {
  5428. c.start = a || this.timeAxis.getStart();
  5429. c.end = f
  5430. }
  5431. if (!b) {
  5432. this.applyViewSettings(d)
  5433. }
  5434. this.timeAxis.reconfigure(c)
  5435. }
  5436. },
  5437. applyViewSettings : function(b) {
  5438. var a = this.getSchedulingView();
  5439. a.setDisplayDateFormat(b.displayDateFormat);
  5440. if (this.orientation === "horizontal") {
  5441. a.setRowHeight(this.rowHeight || b.rowHeight, true)
  5442. }
  5443. },
  5444. getStart : function() {
  5445. return this.timeAxis.getStart()
  5446. },
  5447. getEnd : function() {
  5448. return this.timeAxis.getEnd()
  5449. },
  5450. getViewportCenterDate : function() {
  5451. var b = this.getSchedulingView(), c = b.getEl(), a = c.getScroll(), d;
  5452. if (this.orientation === "vertical") {
  5453. d = [0, a.top + c.getHeight() / 2]
  5454. } else {
  5455. d = [a.left + c.getWidth() / 2, 0]
  5456. }
  5457. return b.getDateFromXY(d, null, true)
  5458. },
  5459. setTimeColumnWidth : function(b, a) {
  5460. this.getSchedulingView().setColumnWidth(b, a)
  5461. },
  5462. onTimeAxisReconfigure : function() {
  5463. this.fireEvent("viewchange", this);
  5464. if (this.stateful && this.lockedGrid) {
  5465. this.saveState()
  5466. }
  5467. },
  5468. getColumnsState : function() {
  5469. var b = this, a = b.lockedGrid.headerCt.getColumnsState();
  5470. return a
  5471. },
  5472. shiftNext : function(a) {
  5473. this.timeAxis.shiftNext(a)
  5474. },
  5475. shiftPrevious : function(a) {
  5476. this.timeAxis.shiftPrevious(a)
  5477. },
  5478. goToNow : function() {
  5479. this.setTimeSpan(new Date())
  5480. },
  5481. setTimeSpan : function(b, a) {
  5482. if (this.timeAxis) {
  5483. this.timeAxis.setTimeSpan(b, a)
  5484. }
  5485. },
  5486. setStart : function(a) {
  5487. this.setTimeSpan(a)
  5488. },
  5489. setEnd : function(a) {
  5490. this.setTimeSpan(null, a)
  5491. },
  5492. getTimeAxis : function() {
  5493. return this.timeAxis
  5494. },
  5495. getResourceByEventRecord : function(a) {
  5496. return a.getResource()
  5497. },
  5498. scrollToDate : function(c, b) {
  5499. var a = this.getSchedulingView(), d = a.getXYFromDate(c, true);
  5500. if (this.orientation == "horizontal") {
  5501. a.getEl().scrollTo("left", Math.max(0, d[0]), b)
  5502. } else {
  5503. a.getEl().scrollTo("top", Math.max(0, d[1]), b)
  5504. }
  5505. },
  5506. getSchedulingView : function() {
  5507. return this.lockable ? this.normalGrid.getView() : this.getView()
  5508. },
  5509. setOrientation : function(a) {
  5510. this.removeCls("sch-" + this.orientation);
  5511. this.addCls("sch-" + a);
  5512. this.orientation = a
  5513. }
  5514. });
  5515. Ext.define("Sch.panel.TimelineTreePanel", {
  5516. extend : "Ext.tree.Panel",
  5517. requires : ["Ext.data.TreeStore"],
  5518. mixins : ["Sch.mixin.TimelinePanel"],
  5519. useArrows : true,
  5520. rootVisible : false,
  5521. constructor : function(a) {
  5522. a = a || {};
  5523. a.animate = false;
  5524. this.callParent(arguments)
  5525. },
  5526. initComponent : function() {
  5527. this.callParent(arguments);
  5528. if (this.lockable
  5529. && this.lockedGrid.headerCt.query("treecolumn").length === 0) {
  5530. Ext.Error
  5531. .raise("You must define an Ext.tree.Column (or use xtype : 'treecolumn').")
  5532. }
  5533. },
  5534. onRootChange : function(a) {
  5535. if (!this.lockable) {
  5536. this.callParent(arguments)
  5537. }
  5538. },
  5539. bindStore : function(b) {
  5540. this.callParent(arguments);
  5541. if (Ext.getVersion("extjs").isGreaterThanOrEqual("4.1.2")) {
  5542. var c = this, a = c.getView();
  5543. if (b.buffered && c.verticalScroll) {
  5544. c.verticalScroller = new Ext.grid.PagingScroller(Ext.apply({
  5545. panel : c,
  5546. store : b,
  5547. view : c.view
  5548. }, c.initialConfig.verticalScroller))
  5549. }
  5550. if (b && b.buffered) {
  5551. a.preserveScrollOnRefresh = true
  5552. } else {
  5553. if (c.invalidateScrollerOnRefresh !== undefined) {
  5554. a.preserveScrollOnRefresh = !c.invalidateScrollerOnRefresh
  5555. }
  5556. }
  5557. }
  5558. }
  5559. }, function() {
  5560. this.override(Sch.mixin.TimelinePanel.prototype.inheritables() || {})
  5561. });
  5562. Ext.define("Sch.plugin.Printable", {
  5563. extend : "Ext.AbstractPlugin",
  5564. lockableScope : "top",
  5565. docType : "<!DOCTYPE HTML>",
  5566. beforePrint : Ext.emptyFn,
  5567. afterPrint : Ext.emptyFn,
  5568. autoPrintAndClose : true,
  5569. fakeBackgroundColor : true,
  5570. scheduler : null,
  5571. constructor : function(a) {
  5572. Ext.apply(this, a)
  5573. },
  5574. init : function(a) {
  5575. this.scheduler = a;
  5576. a.print = Ext.Function.bind(this.print, this)
  5577. },
  5578. mainTpl : new Ext.XTemplate(
  5579. '{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>',
  5580. {
  5581. printLockedHeader : function(a) {
  5582. var b = "";
  5583. if (a.lockedGrid) {
  5584. b += '<div style="left:-' + a.lockedScroll
  5585. + "px;margin-right:-" + a.lockedScroll
  5586. + "px;width:"
  5587. + (a.lockedWidth + a.lockedScroll) + 'px"';
  5588. 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">';
  5589. b += a.lockedHeader;
  5590. b += "</div>"
  5591. }
  5592. return b
  5593. },
  5594. printNormalHeader : function(a) {
  5595. var b = "";
  5596. if (a.normalGrid) {
  5597. b += '<div style="left:'
  5598. + (a.lockedGrid ? a.lockedWidth : "0")
  5599. + "px;width:"
  5600. + a.normalWidth
  5601. + '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">';
  5602. b += '<div style="margin-left:-' + a.normalScroll
  5603. + 'px">' + a.normalHeader + "</div>";
  5604. b += "</div>"
  5605. }
  5606. return b
  5607. },
  5608. printLockedGrid : function(a) {
  5609. var b = "";
  5610. if (a.lockedGrid) {
  5611. b += '<div id="lockedRowsCt" style="left:-'
  5612. + a.lockedScroll + "px;margin-right:-"
  5613. + a.lockedScroll + "px;width:" + a.lockedWidth
  5614. + a.lockedScroll + "px;top:" + a.headerHeight
  5615. + 'px;" class="sch-print-locked-rows-ct '
  5616. + a.innerLockedClasses
  5617. + ' x-grid-inner-locked">';
  5618. b += a.lockedRows;
  5619. b += "</div>"
  5620. }
  5621. return b
  5622. },
  5623. printNormalGrid : function(a) {
  5624. var b = "";
  5625. if (a.normalGrid) {
  5626. b += '<div id="normalRowsCt" style="left:'
  5627. + (a.lockedGrid ? a.lockedWidth : "0")
  5628. + "px;top:" + a.headerHeight + "px;width:"
  5629. + a.normalWidth
  5630. + 'px" class="sch-print-normal-rows-ct '
  5631. + a.innerNormalClasses + '">';
  5632. b += '<div style="position:relative;overflow:visible;margin-left:-'
  5633. + a.normalScroll
  5634. + 'px">'
  5635. + a.normalRows
  5636. + "</div>";
  5637. b += "</div>"
  5638. }
  5639. return b
  5640. }
  5641. }),
  5642. getGridContent : function(l) {
  5643. var k = l.normalGrid, d = l.lockedGrid, m = d.getView(), e = k
  5644. .getView(), h, c, j, g, i, a, f;
  5645. this.beforePrint(l);
  5646. if (d.collapsed && !k.collapsed) {
  5647. a = d.getWidth() + k.getWidth()
  5648. } else {
  5649. a = k.getWidth();
  5650. f = d.getWidth()
  5651. }
  5652. var b = m.store.getRange();
  5653. c = m.tpl.apply(m.collectData(b, 0));
  5654. j = e.tpl.apply(e.collectData(b, 0));
  5655. g = m.el.getScroll().left;
  5656. i = e.el.getScroll().left;
  5657. if (Sch.feature && Sch.feature.AbstractTimeSpan) {
  5658. Ext.each((l.normalGrid.plugins || []).concat(l.columnLinesFeature
  5659. || []), function(n) {
  5660. if (n instanceof Sch.feature.AbstractTimeSpan) {
  5661. j = n.generateMarkup(true) + j
  5662. }
  5663. })
  5664. }
  5665. this.afterPrint(l);
  5666. return {
  5667. normalHeader : k.headerCt.el.dom.innerHTML,
  5668. lockedHeader : d.headerCt.el.dom.innerHTML,
  5669. lockedGrid : !d.collapsed,
  5670. normalGrid : !k.collapsed,
  5671. lockedRows : c,
  5672. normalRows : j,
  5673. lockedScroll : g,
  5674. normalScroll : i,
  5675. lockedWidth : f,
  5676. normalWidth : a,
  5677. headerHeight : k.headerCt.getHeight(),
  5678. innerLockedClasses : d.view.el.dom.className,
  5679. innerNormalClasses : k.view.el.dom.className
  5680. + (this.fakeBackgroundColor
  5681. ? " sch-print-fake-background"
  5682. : ""),
  5683. width : l.getWidth()
  5684. }
  5685. },
  5686. getStylesheets : function() {
  5687. return Ext.getDoc().select('link[rel="stylesheet"]')
  5688. },
  5689. print : function() {
  5690. var g = this.scheduler;
  5691. if (!(this.mainTpl instanceof Ext.Template)) {
  5692. var a = 22;
  5693. this.mainTpl = Ext.create("Ext.XTemplate", this.mainTpl, {
  5694. compiled : true,
  5695. disableFormats : true
  5696. })
  5697. }
  5698. var h = g.getView(), i = this.getStylesheets(), e = Ext
  5699. .get(Ext.core.DomHelper.createDom({
  5700. tag : "div"
  5701. })), b;
  5702. i.each(function(j) {
  5703. e.appendChild(j.dom.cloneNode(true))
  5704. });
  5705. b = e.dom.innerHTML + "";
  5706. var f = this.getGridContent(g), c = this.mainTpl.apply(Ext.apply({
  5707. waitText : this.waitText,
  5708. docType : this.docType,
  5709. htmlClasses : "",
  5710. bodyClasses : Ext.getBody().dom.className,
  5711. componentClasses : g.el.dom.className,
  5712. title : (g.title || ""),
  5713. styles : b,
  5714. totalWidth : g.getWidth(),
  5715. setupScript : "(" + this.setupScript.toString() + ")();"
  5716. }, f));
  5717. var d = window.open("", "printgrid");
  5718. this.printWindow = d;
  5719. d.document.write(c);
  5720. d.document.close();
  5721. if (this.autoPrintAndClose) {
  5722. d.print();
  5723. if (!Ext.isChrome) {
  5724. d.close()
  5725. }
  5726. }
  5727. },
  5728. setupScript : function() {
  5729. var f = document.getElementById("lockedRowsCt"), d = document
  5730. .getElementById("normalRowsCt"), b = f
  5731. && f.getElementsByTagName("tr"), a = d
  5732. && d.getElementsByTagName("tr"), e = a && b ? a.length : 0, c = 0;
  5733. for (; c < e; c++) {
  5734. b[c].style.height = a[c].style.height
  5735. }
  5736. }
  5737. });
  5738. Ext.define("Sch.plugin.Export", {
  5739. extend : "Ext.util.Observable",
  5740. alternateClassName : "Sch.plugin.PdfExport",
  5741. mixins : ["Ext.AbstractPlugin"],
  5742. lockableScope : "top",
  5743. printServer : undefined,
  5744. tpl : new Ext.XTemplate(
  5745. '<!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>',
  5746. {
  5747. disableFormats : true,
  5748. showHeader : function(a) {
  5749. if (a.showHeader) {
  5750. return '<div class="sch-export-header" style="width:'
  5751. + a.totalWidth + 'px"><h2>' + a.column + "/"
  5752. + a.row + "</h2></div>"
  5753. }
  5754. return ""
  5755. }
  5756. }),
  5757. exportStatus : false,
  5758. exportDialogClassName : "Sch.widget.ExportDialog",
  5759. exportDialogConfig : {},
  5760. defaultConfig : {
  5761. format : "A4",
  5762. orientation : "portrait",
  5763. range : "complete",
  5764. showHeader : true
  5765. },
  5766. pageSizes : {
  5767. A5 : {
  5768. width : 5.8,
  5769. height : 8.3
  5770. },
  5771. A4 : {
  5772. width : 8.3,
  5773. height : 11.7
  5774. },
  5775. A3 : {
  5776. width : 11.7,
  5777. height : 16.5
  5778. },
  5779. Letter : {
  5780. width : 8.5,
  5781. height : 11
  5782. }
  5783. },
  5784. openAfterExport : true,
  5785. fileFormat : "pdf",
  5786. DPI : 72,
  5787. constructor : function(a) {
  5788. this.callParent(arguments);
  5789. this.addEvents("hidedialogwindow", "showdialogerror",
  5790. "updateprogressbar");
  5791. this.setFileFormat(this.fileFormat)
  5792. },
  5793. init : function(a) {
  5794. this.scheduler = a;
  5795. a.showExportDialog = Ext.Function.bind(this.showExportDialog, this);
  5796. a.doExport = Ext.Function.bind(this.doExport, this);
  5797. a.isExporting = Ext.Function.bind(this.isExporting, this)
  5798. },
  5799. setFileFormat : function(a) {
  5800. if (typeof a !== "string") {
  5801. this.fileFormat = "pdf"
  5802. } else {
  5803. a = a.toLowerCase();
  5804. if (a === "png") {
  5805. this.fileFormat = a
  5806. } else {
  5807. this.fileFormat = "pdf"
  5808. }
  5809. }
  5810. },
  5811. isExporting : function() {
  5812. return this.exportStatus
  5813. },
  5814. showExportDialog : function() {
  5815. var b = this, a = b.scheduler.getSchedulingView(), c;
  5816. if (b.win) {
  5817. b.win.destroy();
  5818. b.win = null
  5819. }
  5820. b.win = Ext.create(b.exportDialogClassName, {
  5821. plugin : b,
  5822. exportDialogConfig : Ext.apply({
  5823. startDate : this.scheduler.getStart(),
  5824. endDate : this.scheduler.getEnd(),
  5825. rowHeight : a.rowHeight,
  5826. columnWidth : a.getSingleTickInPixels()
  5827. }, b.exportDialogConfig)
  5828. });
  5829. b.win.show()
  5830. },
  5831. getStylesheets : function() {
  5832. var c = Ext.getDoc().select('link[rel="stylesheet"]'), a = Ext
  5833. .get(Ext.core.DomHelper.createDom({
  5834. tag : "div"
  5835. })), b;
  5836. c.each(function(d) {
  5837. a.appendChild(d.dom.cloneNode(true))
  5838. });
  5839. b = a.dom.innerHTML + "";
  5840. return b
  5841. },
  5842. doExport : function(l, i, n) {
  5843. var A = this, m = A.scheduler, o = m.getSchedulingView(), k = A
  5844. .getStylesheets(), y = l || A.defaultConfig;
  5845. A.exportStatus = true;
  5846. A.mask();
  5847. A.fireEvent("updateprogressbar", 0.1);
  5848. if (m.expandAll) {
  5849. m.expandAll()
  5850. }
  5851. var w = m.lockedGrid, p = m.normalGrid, f = o.rowHeight, z = m.timeAxis
  5852. .getTicks(), q = o.getSingleTickInPixels(), b = {
  5853. width : m.getWidth(),
  5854. height : m.getHeight(),
  5855. rowHeight : f,
  5856. columnWidth : q,
  5857. startDate : m.getStart(),
  5858. endDate : m.getEnd(),
  5859. normalWidth : p.getWidth(),
  5860. normalPosition : p.getPosition()
  5861. }, u, g;
  5862. if (y.orientation === "landscape") {
  5863. u = A.pageSizes[y.format].height * A.DPI;
  5864. g = A.pageSizes[y.format].width * A.DPI
  5865. } else {
  5866. u = A.pageSizes[y.format].width * A.DPI;
  5867. g = A.pageSizes[y.format].height * A.DPI
  5868. }
  5869. var x = 41, t = p.headerCt.getHeight(), e = Math.floor(g) - t
  5870. - (y.showHeader ? x : 0);
  5871. if (y.range !== "complete") {
  5872. var d, a, j, c, r;
  5873. if (y.range === "date") {
  5874. d = new Date(y.dateFrom);
  5875. a = new Date(y.dateTo);
  5876. if (Sch.util.Date.getDurationInDays(d, a < 1)) {
  5877. a = Sch.util.Date.add(a, Sch.util.Date.DAY, 1);
  5878. a = Sch.util.Date.constrain(a, m.getStart(), m.getEnd())
  5879. }
  5880. } else {
  5881. if (y.range === "current") {
  5882. j = o.getVisibleDateRange();
  5883. d = j.startDate;
  5884. a = j.endDate
  5885. }
  5886. }
  5887. c = Math.floor(o.timeAxis.getTickFromDate(d));
  5888. r = Math.floor(o.timeAxis.getTickFromDate(a));
  5889. z = z.filter(function(C, B) {
  5890. return B >= c && B <= r
  5891. });
  5892. m.setTimeSpan(d, a)
  5893. }
  5894. m.setWidth(u);
  5895. m.setTimeColumnWidth(q);
  5896. var h = A.calculatePages(y, z, q, u, e), v = {
  5897. ticks : z,
  5898. printHeight : e,
  5899. paperWidth : u,
  5900. headerHeight : t,
  5901. styles : k,
  5902. config : y
  5903. }, s = A.getExportJsonHtml(h, v);
  5904. A.fireEvent("updateprogressbar", 0.4);
  5905. if (A.printServer) {
  5906. Ext.Ajax.request({
  5907. type : "POST",
  5908. url : A.printServer,
  5909. params : {
  5910. html : {
  5911. array : s
  5912. },
  5913. format : y.format,
  5914. orientation : y.orientation,
  5915. range : y.range,
  5916. fileFormat : A.fileFormat
  5917. },
  5918. success : function(B) {
  5919. A.onSuccess(B, i, n)
  5920. },
  5921. failure : function(B) {
  5922. A.onFailure(B, n)
  5923. },
  5924. scope : A
  5925. })
  5926. } else {
  5927. throw "Server url not defined !"
  5928. }
  5929. A.restorePanel(b)
  5930. },
  5931. calculatePages : function(c, p, h, l, b) {
  5932. var m = this, n = m.scheduler, e = n.lockedGrid, a = n
  5933. .getSchedulingView().rowHeight, k = e.getWidth(), j = Math
  5934. .floor(l / h), g = Math.floor((l - k) / h), d = Math
  5935. .ceil((p.length - g) / j)
  5936. + 1, o = n.getSchedulingView().store.getCount(), i = Math
  5937. .floor(b / a), f = Math.ceil(o / i);
  5938. return {
  5939. columnsAmountLocked : g,
  5940. columnsAmountNormal : j,
  5941. rowsAmount : i,
  5942. rowPages : f,
  5943. columnPages : d,
  5944. timeColumnWidth : h,
  5945. lockedGridWidth : k,
  5946. rowHeight : a,
  5947. panelHTML : {}
  5948. }
  5949. },
  5950. getExportJsonHtml : function(g, B) {
  5951. 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;
  5952. for (var z = 0; z < a; z += 1) {
  5953. if (z === 0) {
  5954. j = Ext.Number.constrain((r - 1), z, (D.length - 1));
  5955. n.setTimeSpan(D[z].start, D[j].end)
  5956. } else {
  5957. if (!c) {
  5958. c = n.lockedGrid.hide()
  5959. }
  5960. if (D[j + t]) {
  5961. n.setTimeSpan(D[j + 1].start, D[j + t].end);
  5962. j = j + t
  5963. } else {
  5964. n.setTimeSpan(D[j + 1].start, D[D.length - 1].end)
  5965. }
  5966. }
  5967. n.setTimeColumnWidth(q);
  5968. var u = new RegExp(/x-ie\d?|x-gecko/g), y = Ext.getBody().dom.className
  5969. .replace(u, ""), p = n.el.dom.className;
  5970. for (var v = 0; v < s; v += 1) {
  5971. E.hideRows(h, v);
  5972. o.dom = n.body.dom.innerHTML;
  5973. o.k = v;
  5974. o.i = z;
  5975. e = E.resizePanelHTML(o);
  5976. m = E.tpl.apply(Ext.apply({
  5977. bodyClasses : y,
  5978. bodyHeight : d + x,
  5979. componentClasses : p,
  5980. styles : l,
  5981. showHeader : C.showHeader,
  5982. HTML : e.dom.innerHTML,
  5983. totalWidth : A,
  5984. headerHeight : x,
  5985. column : z + 1,
  5986. row : v + 1
  5987. }));
  5988. f = {
  5989. html : m
  5990. };
  5991. w.push(f);
  5992. E.showRows()
  5993. }
  5994. }
  5995. this.exportStatus = false;
  5996. return Ext.JSON.encode(w)
  5997. },
  5998. resizePanelHTML : function(g) {
  5999. var h = Ext.get(Ext.core.DomHelper.createDom({
  6000. tag : "div",
  6001. html : g.dom
  6002. })), c = this.scheduler, f = c.lockedGrid, d = c.normalGrid, e, a;
  6003. if (Ext.isIE6 || Ext.isIE7 || Ext.isIEQuirks) {
  6004. var b = document.createDocumentFragment();
  6005. b.appendChild(h.dom);
  6006. e = [b.getElementById(c.id + "-targetEl"),
  6007. b.getElementById(c.id + "-innerCt"),
  6008. b.getElementById(f.id), b.getElementById(f.body.id),
  6009. b.getElementById(f.body.child(".x-grid-view").id)];
  6010. a = [b.getElementById(d.id), b.getElementById(d.headerCt.id),
  6011. b.getElementById(d.body.id),
  6012. b.getElementById(d.getView().id)];
  6013. Ext.Array.each(e, function(i) {
  6014. if (i !== null) {
  6015. i.style.height = "100%"
  6016. }
  6017. });
  6018. Ext.Array.each(a, function(j, i) {
  6019. if (j !== null) {
  6020. if (i === 1) {
  6021. j.style.width = "100%"
  6022. } else {
  6023. j.style.height = "100%";
  6024. j.style.width = "100%"
  6025. }
  6026. }
  6027. });
  6028. h.dom.innerHTML = b.firstChild.innerHTML
  6029. } else {
  6030. e = [h.select("#" + c.id + "-targetEl").first(),
  6031. h.select("#" + c.id + "-innerCt").first(),
  6032. h.select("#" + f.id).first(),
  6033. h.select("#" + f.body.id).first(),
  6034. h.select("#" + f.body.child(".x-grid-view").id).first()];
  6035. a = [h.select("#" + d.id).first(),
  6036. h.select("#" + d.headerCt.id).first(),
  6037. h.select("#" + d.body.id).first(),
  6038. h.select("#" + d.getView().id).first()];
  6039. Ext.Array.each(e, function(i) {
  6040. if (i) {
  6041. i.setHeight("100%")
  6042. }
  6043. });
  6044. Ext.Array.each(a, function(j, i) {
  6045. if (i === 1) {
  6046. j.setWidth("100%")
  6047. } else {
  6048. j.applyStyles({
  6049. height : "100%",
  6050. width : "100%"
  6051. })
  6052. }
  6053. })
  6054. }
  6055. return h
  6056. },
  6057. getWin : function() {
  6058. return this.win || null
  6059. },
  6060. onSuccess : function(c, h, b) {
  6061. var d = this, g = d.getWin(), a;
  6062. try {
  6063. a = Ext.JSON.decode(c.responseText)
  6064. } catch (f) {
  6065. this.onFailure(c, b);
  6066. return
  6067. }
  6068. d.fireEvent("updateprogressbar", 1);
  6069. if (a.success) {
  6070. setTimeout(function() {
  6071. d.fireEvent("hidedialogwindow");
  6072. d.unmask();
  6073. if (d.openAfterExport) {
  6074. window.open(a.url, "ExportedPanel")
  6075. }
  6076. }, g ? g.hideTime : 3000)
  6077. } else {
  6078. d.fireEvent("showdialogerror", g, a.msg);
  6079. d.unmask()
  6080. }
  6081. if (h) {
  6082. h.call(this, c)
  6083. }
  6084. },
  6085. onFailure : function(b, a) {
  6086. var c = this.getWin();
  6087. this.fireEvent("showdialogerror", c);
  6088. this.unmask();
  6089. if (a) {
  6090. a.call(this, b)
  6091. }
  6092. },
  6093. hideRows : function(d, f) {
  6094. var c = this.scheduler.lockedGrid.getEl().select(".x-grid-row"), a = this.scheduler.normalGrid
  6095. .getEl().select(".x-grid-row"), g = d * f, b = g + d;
  6096. for (var e = 0; e < a.elements.length; e += 1) {
  6097. if (e < g || e >= b) {
  6098. c.elements[e].className += " sch-none";
  6099. a.elements[e].className += " sch-none"
  6100. }
  6101. }
  6102. },
  6103. showRows : function() {
  6104. var b = this.scheduler.lockedGrid.getEl().select(".x-grid-row"), a = this.scheduler.normalGrid
  6105. .getEl().select(".x-grid-row");
  6106. b.each(function(c) {
  6107. c.removeCls("sch-none")
  6108. });
  6109. a.each(function(c) {
  6110. c.removeCls("sch-none")
  6111. })
  6112. },
  6113. mask : function() {
  6114. var a = Ext.getBody().mask();
  6115. a.addCls("sch-export-mask")
  6116. },
  6117. unmask : function() {
  6118. Ext.getBody().unmask()
  6119. },
  6120. restorePanel : function(a) {
  6121. var b = this.scheduler;
  6122. b.setWidth(a.width);
  6123. b.setHeight(a.height);
  6124. b.setTimeSpan(a.startDate, a.endDate);
  6125. b.setTimeColumnWidth(a.columnWidth, true);
  6126. b.getSchedulingView().setRowHeight(a.rowHeight);
  6127. b.lockedGrid.show();
  6128. b.normalGrid.setWidth(a.normalWidth);
  6129. b.normalGrid.setPosition(a.normalPosition[0])
  6130. },
  6131. destroy : function() {
  6132. if (this.win) {
  6133. this.win.destroy()
  6134. }
  6135. }
  6136. });
  6137. Ext.define("Sch.widget.ResizePicker", {
  6138. extend : "Ext.Panel",
  6139. alias : "widget.dualrangepicker",
  6140. width : 200,
  6141. height : 200,
  6142. border : true,
  6143. collapsible : false,
  6144. bodyStyle : "position:absolute; margin:5px",
  6145. verticalCfg : {
  6146. height : 120,
  6147. value : 24,
  6148. increment : 2,
  6149. minValue : 20,
  6150. maxValue : 80,
  6151. reverse : true,
  6152. disabled : true
  6153. },
  6154. horizontalCfg : {
  6155. width : 120,
  6156. value : 100,
  6157. minValue : 25,
  6158. increment : 5,
  6159. maxValue : 200,
  6160. disable : true
  6161. },
  6162. initComponent : function() {
  6163. var a = this;
  6164. a.addEvents("change", "changecomplete", "select");
  6165. a.horizontalCfg.value = a.dialogConfig.columnWidth;
  6166. a.verticalCfg.value = a.dialogConfig.rowHeight;
  6167. a.verticalCfg.disabled = a.dialogConfig.scrollerDisabled || false;
  6168. a.dockedItems = [a.vertical = new Ext.slider.Single(Ext.apply({
  6169. dock : "left",
  6170. style : "margin-top:10px",
  6171. vertical : true,
  6172. listeners : {
  6173. change : a.onSliderChange,
  6174. changecomplete : a.onSliderChangeComplete,
  6175. scope : a
  6176. }
  6177. }, a.verticalCfg)),
  6178. a.horizontal = new Ext.slider.Single(Ext.apply({
  6179. dock : "top",
  6180. style : "margin-left:28px",
  6181. listeners : {
  6182. change : a.onSliderChange,
  6183. changecomplete : a.onSliderChangeComplete,
  6184. scope : a
  6185. }
  6186. }, a.horizontalCfg))];
  6187. a.callParent(arguments)
  6188. },
  6189. afterRender : function() {
  6190. var b = this;
  6191. b.addCls("sch-ux-range-picker");
  6192. b.valueHandle = this.body.createChild({
  6193. cls : "sch-ux-range-value",
  6194. cn : {
  6195. tag : "span"
  6196. }
  6197. });
  6198. b.valueSpan = this.valueHandle.down("span");
  6199. var a = new Ext.dd.DD(this.valueHandle);
  6200. Ext.apply(a, {
  6201. startDrag : function() {
  6202. b.dragging = true;
  6203. this.constrainTo(b.body)
  6204. },
  6205. onDrag : function() {
  6206. b.onHandleDrag.apply(b, arguments)
  6207. },
  6208. endDrag : function() {
  6209. b.onHandleEndDrag.apply(b, arguments);
  6210. b.dragging = false
  6211. },
  6212. scope : this
  6213. });
  6214. this.setValues(this.getValues());
  6215. this.callParent(arguments);
  6216. this.body.on("click", this.onBodyClick, this)
  6217. },
  6218. onBodyClick : function(c, a) {
  6219. var b = [c.getXY()[0] - 8 - this.body.getX(),
  6220. c.getXY()[1] - 8 - this.body.getY()];
  6221. this.valueHandle.setLeft(Ext.Number.constrain(b[0], 0, this
  6222. .getAvailableWidth()));
  6223. this.valueHandle.setTop(Ext.Number.constrain(b[1], 0, this
  6224. .getAvailableHeight()));
  6225. this.setValues(this.getValuesFromXY([this.valueHandle.getLeft(true),
  6226. this.valueHandle.getTop(true)]));
  6227. this.onSliderChangeComplete()
  6228. },
  6229. getAvailableWidth : function() {
  6230. return this.body.getWidth() - 18
  6231. },
  6232. getAvailableHeight : function() {
  6233. return this.body.getHeight() - 18
  6234. },
  6235. onHandleDrag : function() {
  6236. this.setValues(this.getValuesFromXY([this.valueHandle.getLeft(true),
  6237. this.valueHandle.getTop(true)]))
  6238. },
  6239. onHandleEndDrag : function() {
  6240. this.setValues(this.getValuesFromXY([this.valueHandle.getLeft(true),
  6241. this.valueHandle.getTop(true)]))
  6242. },
  6243. getValuesFromXY : function(d) {
  6244. var c = d[0] / this.getAvailableWidth();
  6245. var a = d[1] / this.getAvailableHeight();
  6246. var e = Math
  6247. .round((this.horizontalCfg.maxValue - this.horizontalCfg.minValue)
  6248. * c);
  6249. var b = Math
  6250. .round((this.verticalCfg.maxValue - this.verticalCfg.minValue)
  6251. * a)
  6252. + this.verticalCfg.minValue;
  6253. return [e + this.horizontalCfg.minValue, b]
  6254. },
  6255. getXYFromValues : function(d) {
  6256. var b = this.horizontalCfg.maxValue - this.horizontalCfg.minValue;
  6257. var f = this.verticalCfg.maxValue - this.verticalCfg.minValue;
  6258. var a = Math.round((d[0] - this.horizontalCfg.minValue)
  6259. * this.getAvailableWidth() / b);
  6260. var c = d[1] - this.verticalCfg.minValue;
  6261. var e = Math.round(c * this.getAvailableHeight() / f);
  6262. return [a, e]
  6263. },
  6264. updatePosition : function() {
  6265. var a = this.getValues();
  6266. var b = this.getXYFromValues(a);
  6267. this.valueHandle.setLeft(Ext.Number.constrain(b[0], 0, this
  6268. .getAvailableWidth()));
  6269. if (this.verticalCfg.disabled) {
  6270. this.valueHandle.setTop(this.dialogConfig.rowHeight)
  6271. } else {
  6272. this.valueHandle.setTop(Ext.Number.constrain(b[1], 0, this
  6273. .getAvailableHeight()))
  6274. }
  6275. this.positionValueText();
  6276. this.setValueText(a)
  6277. },
  6278. positionValueText : function() {
  6279. var a = this.valueHandle.getTop(true);
  6280. var b = this.valueHandle.getLeft(true);
  6281. this.valueSpan.setLeft(b > 30 ? -30 : 10);
  6282. this.valueSpan.setTop(a > 10 ? -20 : 20)
  6283. },
  6284. setValueText : function(a) {
  6285. if (this.verticalCfg.disabled) {
  6286. a[1] = this.dialogConfig.rowHeight
  6287. }
  6288. this.valueSpan.update("[" + a.toString() + "]")
  6289. },
  6290. setValues : function(a) {
  6291. this.horizontal.setValue(a[0]);
  6292. if (this.verticalCfg.reverse) {
  6293. if (!this.verticalCfg.disabled) {
  6294. this.vertical.setValue(this.verticalCfg.maxValue
  6295. + this.verticalCfg.minValue - a[1])
  6296. }
  6297. } else {
  6298. if (!this.verticalCfg.disabled) {
  6299. this.vertical.setValue(a[1])
  6300. }
  6301. }
  6302. if (!this.dragging) {
  6303. this.updatePosition()
  6304. }
  6305. this.positionValueText();
  6306. this.setValueText(a)
  6307. },
  6308. getValues : function() {
  6309. var a = this.vertical.getValue();
  6310. if (this.verticalCfg.reverse) {
  6311. a = this.verticalCfg.maxValue - a + this.verticalCfg.minValue
  6312. }
  6313. return [this.horizontal.getValue(), a]
  6314. },
  6315. onSliderChange : function() {
  6316. this.fireEvent("change", this, this.getValues());
  6317. if (!this.dragging) {
  6318. this.updatePosition()
  6319. }
  6320. },
  6321. onSliderChangeComplete : function() {
  6322. this.fireEvent("changecomplete", this, this.getValues())
  6323. },
  6324. afterLayout : function() {
  6325. this.callParent(arguments);
  6326. this.updatePosition()
  6327. }
  6328. });
  6329. Ext.define("Sch.widget.ExportDialogForm", {
  6330. extend : "Ext.form.Panel",
  6331. requires : ["Ext.ProgressBar", "Sch.widget.ResizePicker"],
  6332. border : false,
  6333. bodyPadding : "10 10 0 10",
  6334. autoHeight : true,
  6335. initComponent : function() {
  6336. var a = this;
  6337. a.createFields();
  6338. Ext.apply(this, {
  6339. fieldDefaults : {
  6340. labelAlign : "top",
  6341. labelWidth : 100,
  6342. anchor : "90%"
  6343. },
  6344. items : [a.rangeField, a.resizePicker, a.dateFromField,
  6345. a.dateToField, a.showHeaderField, a.formatField,
  6346. a.orientationField,
  6347. a.progressBar || a.createProgressBar()]
  6348. });
  6349. a.callParent(arguments);
  6350. a.on({
  6351. hideprogressbar : a.hideProgressBar,
  6352. showprogressbar : a.showProgressBar,
  6353. updateprogressbar : a.updateProgressBar,
  6354. scope : a
  6355. })
  6356. },
  6357. createFields : function() {
  6358. var b = this, a = b.dialogConfig;
  6359. b.rangeField = new Ext.form.field.ComboBox({
  6360. xtype : "combo",
  6361. value : "complete",
  6362. triggerAction : "all",
  6363. cls : "sch-export-dialog-range",
  6364. forceSelection : true,
  6365. editable : false,
  6366. fieldLabel : a.rangeFieldLabel,
  6367. name : "range",
  6368. queryMode : "local",
  6369. displayField : "name",
  6370. valueField : "value",
  6371. store : Ext.create("Ext.data.Store", {
  6372. fields : ["name", "value"],
  6373. data : [{
  6374. name : a.completeView,
  6375. value : "complete"
  6376. }, {
  6377. name : a.dateRange,
  6378. value : "date"
  6379. }, {
  6380. name : a.currentView,
  6381. value : "current"
  6382. }]
  6383. }),
  6384. listeners : {
  6385. change : b.onRangeChange,
  6386. scope : b
  6387. }
  6388. });
  6389. b.resizePicker = new Sch.widget.ResizePicker({
  6390. dialogConfig : a,
  6391. hidden : true,
  6392. padding : "0 0 5 0"
  6393. });
  6394. b.dateFromField = new Ext.form.field.Date({
  6395. fieldLabel : a.dateRangeFrom,
  6396. labelAlign : "left",
  6397. labelWidth : 80,
  6398. baseBodyCls : "sch-exportdialogform-date",
  6399. padding : "10 0 5 0",
  6400. name : "dateFrom",
  6401. format : a.dateRangeFormat || Ext.Date.defaultFormat,
  6402. hidden : true,
  6403. allowBlank : false,
  6404. maxValue : a.endDate,
  6405. minValue : a.startDate,
  6406. value : a.startDate,
  6407. validator : function(c) {
  6408. return Ext.Date.parse(c, this.format) >= new Date(a.startDate)
  6409. }
  6410. });
  6411. b.dateToField = new Ext.form.field.Date({
  6412. fieldLabel : a.dateRangeTo,
  6413. labelAlign : "left",
  6414. labelWidth : 80,
  6415. name : "dateTo",
  6416. format : a.dateRangeFormat || Ext.Date.defaultFormat,
  6417. baseBodyCls : "sch-exportdialogform-date",
  6418. hidden : true,
  6419. allowBlank : false,
  6420. maxValue : a.endDate,
  6421. minValue : a.startDate,
  6422. value : a.endDate,
  6423. validator : function(c) {
  6424. return Ext.Date.parse(c, this.format) <= new Date(a.endDate)
  6425. }
  6426. });
  6427. b.showHeaderField = new Ext.form.field.Checkbox({
  6428. xtype : "checkboxfield",
  6429. fieldLabel : b.dialogConfig.showHeaderLabel,
  6430. name : "showHeader",
  6431. checked : true
  6432. });
  6433. b.formatField = new Ext.form.field.ComboBox({
  6434. value : "A4",
  6435. triggerAction : "all",
  6436. forceSelection : true,
  6437. editable : false,
  6438. fieldLabel : a.formatFieldLabel,
  6439. name : "format",
  6440. queryMode : "local",
  6441. store : ["A5", "A4", "A3", "Letter"]
  6442. });
  6443. b.orientationField = new Ext.form.field.ComboBox({
  6444. value : "portrait",
  6445. triggerAction : "all",
  6446. baseBodyCls : "sch-exportdialogform-orientation",
  6447. forceSelection : true,
  6448. editable : false,
  6449. fieldLabel : b.dialogConfig.orientationFieldLabel,
  6450. afterSubTpl : new Ext.XTemplate('<span id="sch-exportdialog-imagePortrait"></span><span id="sch-exportdialog-imageLandscape" class="sch-none"></span>'),
  6451. name : "orientation",
  6452. displayField : "name",
  6453. valueField : "value",
  6454. queryMode : "local",
  6455. store : Ext.create("Ext.data.Store", {
  6456. fields : ["name", "value"],
  6457. data : [{
  6458. name : a.orientationPortrait,
  6459. value : "portrait"
  6460. }, {
  6461. name : a.orientationLandscape,
  6462. value : "landscape"
  6463. }]
  6464. }),
  6465. listeners : {
  6466. change : function(d, c) {
  6467. switch (c) {
  6468. case "landscape" :
  6469. Ext.fly("sch-exportdialog-imagePortrait")
  6470. .toggleCls("sch-none");
  6471. Ext.fly("sch-exportdialog-imageLandscape")
  6472. .toggleCls("sch-none");
  6473. break;
  6474. case "portrait" :
  6475. Ext.fly("sch-exportdialog-imagePortrait")
  6476. .toggleCls("sch-none");
  6477. Ext.fly("sch-exportdialog-imageLandscape")
  6478. .toggleCls("sch-none");
  6479. break
  6480. }
  6481. }
  6482. }
  6483. })
  6484. },
  6485. createProgressBar : function() {
  6486. return this.progressBar = new Ext.ProgressBar({
  6487. text : this.config.progressBarText,
  6488. animate : true,
  6489. hidden : true,
  6490. id : "print-widget-progressbar"
  6491. })
  6492. },
  6493. onRangeChange : function(b, a) {
  6494. switch (a) {
  6495. case "complete" :
  6496. this.dateFromField.hide();
  6497. this.dateToField.hide();
  6498. this.resizePicker.hide();
  6499. break;
  6500. case "date" :
  6501. this.dateFromField.show();
  6502. this.dateToField.show();
  6503. this.resizePicker.hide();
  6504. break;
  6505. case "current" :
  6506. this.dateFromField.hide();
  6507. this.dateToField.hide();
  6508. this.resizePicker.show();
  6509. this.resizePicker.expand(true);
  6510. break
  6511. }
  6512. },
  6513. showProgressBar : function() {
  6514. if (this.progressBar) {
  6515. this.progressBar.show()
  6516. }
  6517. },
  6518. hideProgressBar : function() {
  6519. if (this.progressBar) {
  6520. this.progressBar.hide()
  6521. }
  6522. },
  6523. updateProgressBar : function(a) {
  6524. if (this.progressBar) {
  6525. this.progressBar.updateProgress(a)
  6526. }
  6527. }
  6528. });
  6529. Ext.define("Sch.widget.ExportDialog", {
  6530. alternateClassName : "Sch.widget.PdfExportDialog",
  6531. extend : "Ext.window.Window",
  6532. alias : "widget.exportdialog",
  6533. modal : false,
  6534. width : 240,
  6535. cls : "sch-exportdialog",
  6536. frame : false,
  6537. layout : "card",
  6538. draggable : false,
  6539. padding : 0,
  6540. plugin : null,
  6541. hideTime : 2000,
  6542. buttonsPanel : null,
  6543. buttonsPanelScope : null,
  6544. progressBar : null,
  6545. generalError : "An error occured, try again.",
  6546. title : "Export Settings",
  6547. formatFieldLabel : "Paper format",
  6548. orientationFieldLabel : "Orientation",
  6549. rangeFieldLabel : "Export range",
  6550. showHeaderLabel : "Add page number",
  6551. orientationPortrait : "Portrait",
  6552. orientationLandscape : "Landscape",
  6553. completeView : "Complete schedule",
  6554. currentView : "Current view",
  6555. dateRange : "Date range",
  6556. dateRangeFrom : "Export from",
  6557. pickerText : "Resize column/rows to desired value",
  6558. dateRangeTo : "Export to",
  6559. exportButtonText : "Export",
  6560. cancelButtonText : "Cancel",
  6561. progressBarText : "Exporting...",
  6562. dateRangeFormat : "",
  6563. requires : ["Sch.widget.ExportDialogForm"],
  6564. constructor : function(a) {
  6565. Ext.apply(this, a.exportDialogConfig);
  6566. this.config = Ext.apply({
  6567. progressBarText : this.progressBarText,
  6568. cancelButtonText : this.cancelButtonText,
  6569. exportButtonText : this.exportButtonText,
  6570. dateRangeTo : this.dateRangeTo,
  6571. pickerText : this.pickerText,
  6572. dateRangeFrom : this.dateRangeFrom,
  6573. dateRange : this.dateRange,
  6574. currentView : this.currentView,
  6575. formatFieldLabel : this.formatFieldLabel,
  6576. orientationFieldLabel : this.orientationFieldLabel,
  6577. rangeFieldLabel : this.rangeFieldLabel,
  6578. showHeaderLabel : this.showHeaderLabel,
  6579. orientationPortrait : this.orientationPortrait,
  6580. orientationLandscape : this.orientationLandscape,
  6581. completeView : this.completeView,
  6582. dateRangeFormat : this.dateRangeFormat
  6583. }, a.exportDialogConfig);
  6584. this.callParent(arguments)
  6585. },
  6586. initComponent : function() {
  6587. var b = this, a = {
  6588. hidedialogwindow : b.destroy,
  6589. showdialogerror : b.showError,
  6590. updateprogressbar : function(c) {
  6591. b.fireEvent("updateprogressbar", c)
  6592. },
  6593. scope : this
  6594. };
  6595. Ext.apply(this, {
  6596. items : [b.form = b.buildForm(b.config),
  6597. b.createMessageElement()],
  6598. fbar : b.buildButtons(b.buttonsPanelScope || b)
  6599. });
  6600. b.callParent(arguments);
  6601. b.plugin.on(a)
  6602. },
  6603. afterRender : function() {
  6604. var a = this;
  6605. a.on("changecomplete", function(c, b) {
  6606. a.plugin.scheduler.setTimeColumnWidth(b[0], true);
  6607. if (!a.config.scrollerDisabled) {
  6608. if (a.form.resizePicker.verticalCfg.reverse) {
  6609. var d = b[1];
  6610. a.plugin.scheduler.getSchedulingView()
  6611. .setRowHeight(d)
  6612. } else {
  6613. a.plugin.scheduler.getSchedulingView()
  6614. .setRowHeight(b[1])
  6615. }
  6616. }
  6617. });
  6618. a.relayEvents(a.form.resizePicker, ["change", "changecomplete",
  6619. "select"]);
  6620. a.form.relayEvents(a, ["updateprogressbar", "hideprogressbar",
  6621. "showprogressbar"]);
  6622. a.callParent(arguments);
  6623. a.switchTab(0)
  6624. },
  6625. createMessageElement : function() {
  6626. var a = this;
  6627. return a.messageElement = new Ext.Component({
  6628. autoEl : {
  6629. tag : "div",
  6630. cls : "sch-exportdialog-msg"
  6631. }
  6632. })
  6633. },
  6634. buildButtons : function(a) {
  6635. return [{
  6636. xtype : "button",
  6637. scale : "medium",
  6638. text : this.exportButtonText,
  6639. handler : function() {
  6640. var c = this.form.getForm();
  6641. if (c.isValid()) {
  6642. var b = c.getValues();
  6643. this.fireEvent("showprogressbar");
  6644. this.plugin.doExport(b)
  6645. }
  6646. },
  6647. scope : a
  6648. }, {
  6649. xtype : "button",
  6650. scale : "medium",
  6651. text : this.cancelButtonText,
  6652. handler : function() {
  6653. this.destroy()
  6654. },
  6655. scope : a
  6656. }]
  6657. },
  6658. buildForm : function(a) {
  6659. return new Sch.widget.ExportDialogForm({
  6660. progressBar : this.progressBar,
  6661. dialogConfig : a
  6662. })
  6663. },
  6664. switchTab : function(a) {
  6665. this.getLayout().setActiveItem(a)
  6666. },
  6667. showError : function(b, a) {
  6668. var c = b, d = a || c.generalError;
  6669. c.fireEvent("hideprogressbar");
  6670. c.switchTab(1);
  6671. c.messageElement.getEl().setHTML(d);
  6672. setTimeout(function() {
  6673. c.hide()
  6674. }, c.hideTime)
  6675. }
  6676. });
  6677. Ext.define("Gnt.model.WeekAvailability", {
  6678. extend : "Sch.model.Range",
  6679. customizableFields : [{
  6680. name : "Availability"
  6681. }],
  6682. availabilityField : "Availability",
  6683. set : function(b, a) {
  6684. if (b === this.nameField) {
  6685. Ext.Array.each(this.getAvailability(), function(c) {
  6686. c.setName(a)
  6687. })
  6688. }
  6689. this.callParent(arguments)
  6690. },
  6691. getAvailability : function() {
  6692. return this.get(this.availabilityField) || []
  6693. },
  6694. setAvailability : function(b) {
  6695. var a = this.getName();
  6696. Ext.Array.each(b, function(c) {
  6697. c.setName(a)
  6698. });
  6699. this.set(this.availabilityField, b)
  6700. }
  6701. });
  6702. Ext.define("Gnt.model.CalendarDay", {
  6703. requires : ["Ext.data.Types"],
  6704. extend : "Sch.model.Customizable",
  6705. idProperty : "Id",
  6706. customizableFields : [{
  6707. name : "Date",
  6708. type : "date",
  6709. dateFormat : "c",
  6710. convert : function(b, a) {
  6711. if (!b) {
  6712. return
  6713. }
  6714. var c = Ext.data.Types.DATE.convert.call(this, b);
  6715. if (c) {
  6716. Ext.Date.clearTime(c)
  6717. }
  6718. if (a.data[a.idProperty] == null) {
  6719. a.data[a.idProperty] = c - 0
  6720. }
  6721. return c
  6722. }
  6723. }, {
  6724. name : "Id"
  6725. }, {
  6726. name : "IsWorkingDay",
  6727. type : "boolean",
  6728. defaultValue : false
  6729. }, {
  6730. name : "Cls",
  6731. defaultValue : "gnt-holiday"
  6732. }, "Name", {
  6733. name : "Availability",
  6734. convert : function(b, a) {
  6735. if (b) {
  6736. return Ext.typeOf(b) === "string" ? [b] : b
  6737. } else {
  6738. return []
  6739. }
  6740. }
  6741. }],
  6742. availabilityCache : null,
  6743. dateField : "Date",
  6744. isWorkingDayField : "IsWorkingDay",
  6745. clsField : "Cls",
  6746. nameField : "Name",
  6747. availabilityField : "Availability",
  6748. setDate : function(b) {
  6749. var a = Ext.Date.clearTime(b, true);
  6750. this.data[this.idProperty] = a - 0;
  6751. this.set(this.dateField, a)
  6752. },
  6753. clearDate : function() {
  6754. this.data[this.idProperty] = null
  6755. },
  6756. getAvailability : function(b) {
  6757. var c = this;
  6758. if (b) {
  6759. return this.get(this.availabilityField)
  6760. }
  6761. if (this.availabilityCache) {
  6762. return this.availabilityCache
  6763. }
  6764. var a = [];
  6765. Ext.Array.each(this.get(this.availabilityField), function(d) {
  6766. a.push(Ext.typeOf(d) === "string" ? c
  6767. .parseInterval(d) : d)
  6768. });
  6769. this.verifyAvailability(a);
  6770. return this.availabilityCache = a
  6771. },
  6772. setAvailability : function(a) {
  6773. this.availabilityCache = null;
  6774. this.set(this.availabilityField, this.stringifyIntervals(a));
  6775. this.getAvailability()
  6776. },
  6777. verifyAvailability : function(b) {
  6778. b.sort(function(f, e) {
  6779. return f.startTime - e.startTime
  6780. });
  6781. Ext.Array.each(b, function(e) {
  6782. if (e.startTime > e.endTime) {
  6783. throw "Start time is greater than end time"
  6784. }
  6785. });
  6786. for (var a = 1; a < b.length; a++) {
  6787. var c = b[a - 1];
  6788. var d = b[a];
  6789. if (c.endTime > d.startTime) {
  6790. throw "Availability intervals should not intersect"
  6791. }
  6792. }
  6793. },
  6794. prependZero : function(a) {
  6795. return a < 10 ? "0" + a : a
  6796. },
  6797. stringifyInterval : function(b) {
  6798. var c = b.startTime;
  6799. var a = b.endTime;
  6800. return this.prependZero(c.getHours()) + ":"
  6801. + this.prependZero(c.getMinutes()) + "-"
  6802. + this.prependZero(a.getHours()) + ":"
  6803. + this.prependZero(a.getMinutes())
  6804. },
  6805. stringifyIntervals : function(b) {
  6806. var c = this;
  6807. var a = [];
  6808. Ext.Array.each(b, function(d) {
  6809. if (Ext.typeOf(d) === "string") {
  6810. a.push(d)
  6811. } else {
  6812. a.push(c.stringifyInterval(d))
  6813. }
  6814. });
  6815. return a
  6816. },
  6817. parseInterval : function(b) {
  6818. var a = /(\d\d):(\d\d)-(\d\d):(\d\d)/.exec(b);
  6819. if (!a) {
  6820. throw "Invalid format for availability string: " + b
  6821. + ". It should have exact format: hh:mm-hh:mm"
  6822. }
  6823. return {
  6824. startTime : new Date(0, 0, 0, a[1], a[2]),
  6825. endTime : new Date(0, 0, 0, a[3], a[4])
  6826. }
  6827. },
  6828. getTotalHours : function() {
  6829. return this.getTotalMS() / 1000 / 60 / 60
  6830. },
  6831. getTotalMS : function() {
  6832. var a = 0;
  6833. Ext.Array.each(this.getAvailability(), function(b) {
  6834. a += b.endTime - b.startTime
  6835. });
  6836. return a
  6837. },
  6838. addAvailabilityInterval : function(d, b) {
  6839. var a;
  6840. if (d instanceof Date) {
  6841. a = {
  6842. startTime : d,
  6843. endTime : b
  6844. }
  6845. } else {
  6846. a = this.parseInterval(d + (b ? "-" + b : ""))
  6847. }
  6848. var c = this.getAvailability().concat(a);
  6849. this.verifyAvailability(c);
  6850. this.setAvailability(c)
  6851. },
  6852. removeAvailbilityInterval : function(a) {
  6853. var b = this.getAvailability();
  6854. b.splice(a, 1);
  6855. this.setAvailability(b)
  6856. },
  6857. getAvailabilityIntervalsFor : function(d) {
  6858. d = typeof d == "number" ? new Date(d) : d;
  6859. var c = d.getFullYear();
  6860. var e = d.getMonth();
  6861. var b = d.getDate();
  6862. var a = [];
  6863. Ext.Array.each(this.getAvailability(), function(f) {
  6864. var g = f.endTime.getDate();
  6865. a.push({
  6866. startDate : new Date(c, e, b,
  6867. f.startTime.getHours(),
  6868. f.startTime.getMinutes()),
  6869. endDate : new Date(c, e, b
  6870. + (g == 1 ? 1 : 0),
  6871. f.endTime.getHours(), f.endTime
  6872. .getMinutes())
  6873. })
  6874. });
  6875. return a
  6876. },
  6877. getAvailabilityStartFor : function(b) {
  6878. var a = this.getAvailabilityIntervalsFor(b);
  6879. if (!a.length) {
  6880. return null
  6881. }
  6882. return a[0].startDate
  6883. },
  6884. getAvailabilityEndFor : function(b) {
  6885. var a = this.getAvailabilityIntervalsFor(b);
  6886. if (!a.length) {
  6887. return null
  6888. }
  6889. return a[a.length - 1].endDate
  6890. }
  6891. });
  6892. Ext.define("Gnt.model.Assignment", {
  6893. extend : "Sch.model.Customizable",
  6894. idProperty : "Id",
  6895. customizableFields : [{
  6896. name : "Id"
  6897. }, {
  6898. name : "ResourceId"
  6899. }, {
  6900. name : "TaskId"
  6901. }, {
  6902. name : "Units",
  6903. type : "float",
  6904. defaultValue : 100
  6905. }],
  6906. resourceIdField : "ResourceId",
  6907. taskIdField : "TaskId",
  6908. unitsField : "Units",
  6909. isPersistable : function() {
  6910. var a = this.getTask(), b = this.getResource();
  6911. return a && !a.phantom && b && !b.phantom
  6912. },
  6913. getUnits : function() {
  6914. return Math.max(0, this.get(this.unitsField))
  6915. },
  6916. setUnits : function(a) {
  6917. if (a < 0) {
  6918. throw "`Units` value for an assignment can't be less than 0"
  6919. }
  6920. this.set(this.unitsField, a)
  6921. },
  6922. getResourceName : function() {
  6923. var a = this.stores[0].getResourceStore().getById(this.getResourceId());
  6924. if (a) {
  6925. return a.getName()
  6926. }
  6927. return ""
  6928. },
  6929. getTask : function(a) {
  6930. return (a || this.stores[0].getTaskStore()).getById(this.getTaskId())
  6931. },
  6932. getResource : function() {
  6933. return this.stores[0].getResourceStore().getByInternalId(this
  6934. .getResourceId())
  6935. },
  6936. getInternalId : function() {
  6937. return this.getId() || this.internalId
  6938. },
  6939. getEffort : function(b) {
  6940. var a = this.getTask();
  6941. var c = 0;
  6942. a.forEachAvailabilityIntervalWithResources({
  6943. startDate : a.getStartDate(),
  6944. endDate : a.getEndDate(),
  6945. resources : [this.getResource()]
  6946. }, function(g, f, e) {
  6947. var h;
  6948. for (var d in e) {
  6949. h = e[d].units
  6950. }
  6951. c += (f - g) * h / 100
  6952. });
  6953. return a.getProjectCalendar().convertMSDurationToUnit(c,
  6954. b || a.getEffortUnit())
  6955. }
  6956. });
  6957. Ext.define("Gnt.model.Dependency", {
  6958. extend : "Sch.model.Customizable",
  6959. inheritableStatics : {
  6960. Type : {
  6961. StartToStart : 0,
  6962. StartToEnd : 1,
  6963. EndToStart : 2,
  6964. EndToEnd : 3
  6965. }
  6966. },
  6967. idProperty : "Id",
  6968. customizableFields : [{
  6969. name : "Id"
  6970. }, {
  6971. name : "From"
  6972. }, {
  6973. name : "To"
  6974. }, {
  6975. name : "Type",
  6976. type : "int",
  6977. defaultValue : 2
  6978. }, {
  6979. name : "Lag",
  6980. type : "number",
  6981. defaultValue : 0
  6982. }, {
  6983. name : "LagUnit",
  6984. type : "string",
  6985. defaultValue : "d",
  6986. convert : function(a) {
  6987. return a || "d"
  6988. }
  6989. }, {
  6990. name : "Cls"
  6991. }],
  6992. fromField : "From",
  6993. toField : "To",
  6994. typeField : "Type",
  6995. lagField : "Lag",
  6996. lagUnitField : "LagUnit",
  6997. clsField : "Cls",
  6998. fromTask : null,
  6999. toTask : null,
  7000. constructor : function(a) {
  7001. this.callParent(arguments);
  7002. if (a) {
  7003. if (a.fromTask) {
  7004. if (a.fromTask instanceof Gnt.model.Task) {
  7005. this.setSourceTask(a.fromTask)
  7006. } else {
  7007. this.setSourceId(a.fromTask)
  7008. }
  7009. }
  7010. if (a.toTask) {
  7011. if (a.toTask instanceof Gnt.model.Task) {
  7012. this.setTargetTask(a.toTask)
  7013. } else {
  7014. this.setTargetId(a.toTask)
  7015. }
  7016. }
  7017. if (Ext.isDefined(a.type)) {
  7018. this.setType(a.type)
  7019. }
  7020. if (Ext.isDefined(a.lag)) {
  7021. this.setLag(a.lag)
  7022. }
  7023. if (Ext.isDefined(a.lagUnit)) {
  7024. this.setLagUnit(a.lagUnit)
  7025. }
  7026. }
  7027. },
  7028. getTaskStore : function() {
  7029. return this.stores[0].taskStore
  7030. },
  7031. getSourceTask : function(a) {
  7032. return (a || this.getTaskStore()).getById(this.getSourceId())
  7033. },
  7034. setSourceTask : function(a) {
  7035. this.setSourceId(a.getId() || a.internalId)
  7036. },
  7037. getTargetTask : function(a) {
  7038. return (a || this.getTaskStore()).getById(this.getTargetId())
  7039. },
  7040. setTargetTask : function(a) {
  7041. this.setTargetId(a.getId() || a.internalId)
  7042. },
  7043. getSourceId : function() {
  7044. return this.get(this.fromField)
  7045. },
  7046. setSourceId : function(a) {
  7047. this.set(this.fromField, a)
  7048. },
  7049. getTargetId : function() {
  7050. return this.get(this.toField)
  7051. },
  7052. setTargetId : function(a) {
  7053. this.set(this.toField, a)
  7054. },
  7055. getLagUnit : function() {
  7056. return this.get(this.lagUnitField) || "d"
  7057. },
  7058. isPersistable : function() {
  7059. var a = this.getSourceTask(), b = this.getTargetTask();
  7060. return a && !a.phantom && b && !b.phantom
  7061. },
  7062. isValid : function(b) {
  7063. var c = this.callParent(arguments), d = this.getSourceId(), a = this
  7064. .getTargetId();
  7065. if (c) {
  7066. c = Ext.isNumber(this.getType()) && !Ext.isEmpty(d)
  7067. && !Ext.isEmpty(a)
  7068. }
  7069. if (c && b !== false && this.stores[0]) {
  7070. c = this.stores[0].isValidDependency(d, a, true)
  7071. }
  7072. return c
  7073. }
  7074. });
  7075. Ext.define("Gnt.model.Resource", {
  7076. extend : "Sch.model.Resource",
  7077. customizableFields : ["CalendarId"],
  7078. calendarIdField : "CalendarId",
  7079. getTaskStore : function() {
  7080. return this.stores[0].getTaskStore()
  7081. },
  7082. getEventStore : function() {
  7083. return this.getTaskStore()
  7084. },
  7085. getEvents : function() {
  7086. return this.getTasks()
  7087. },
  7088. getTasks : function() {
  7089. var a = [];
  7090. this.forEachAssignment(function(b) {
  7091. var c = b.getTask();
  7092. if (c) {
  7093. a.push(c)
  7094. }
  7095. });
  7096. return a
  7097. },
  7098. getCalendar : function(a) {
  7099. return a ? this.getOwnCalendar() : this.getOwnCalendar()
  7100. || this.getProjectCalendar()
  7101. },
  7102. getOwnCalendar : function() {
  7103. var a = this.getCalendarId();
  7104. return a ? Gnt.data.Calendar.getCalendar(a) : null
  7105. },
  7106. getProjectCalendar : function() {
  7107. return this.stores[0].getTaskStore().getCalendar()
  7108. },
  7109. setCalendar : function(a) {
  7110. },
  7111. getInternalId : function() {
  7112. return this.getId() || this.internalId
  7113. },
  7114. assignTo : function(a, c) {
  7115. var b = a instanceof Gnt.model.Task ? a : this.getTaskStore()
  7116. .getById(a);
  7117. return b.assign(this, c)
  7118. },
  7119. unassignFrom : function() {
  7120. return this.unAssignFrom.apply(this, arguments)
  7121. },
  7122. unAssignFrom : function(a) {
  7123. var b = a instanceof Gnt.model.Task ? a : this.getTaskStore()
  7124. .getById(a);
  7125. b.unAssign(this)
  7126. },
  7127. forEachAssignment : function(b, a) {
  7128. a = a || this;
  7129. var c = this.getInternalId();
  7130. this.getTaskStore().getAssignmentStore().each(function(d) {
  7131. if (d.getResourceId() == c) {
  7132. return b.call(a, d)
  7133. }
  7134. })
  7135. },
  7136. collectAvailabilityIntervalPoints : function(e, f, b, h, c) {
  7137. for (var d = 0; d < e.length; d++) {
  7138. var a = e[d];
  7139. var g = a.startDate - 0;
  7140. var i = a.endDate - 0;
  7141. if (!h[g]) {
  7142. h[g] = [];
  7143. c.push(g)
  7144. }
  7145. h[g].push(f(g));
  7146. if (!h[i]) {
  7147. h[i] = [];
  7148. c.push(i)
  7149. }
  7150. h[i].push(b(i))
  7151. }
  7152. },
  7153. forEachAvailabilityIntervalWithTasks : function(d, f, a) {
  7154. a = a || this;
  7155. var c = d.startDate;
  7156. var t = d.endDate;
  7157. if (!c || !t) {
  7158. throw "Both `startDate` and `endDate` are required for `forEachAvailabilityIntervalWithTasks`"
  7159. }
  7160. var g = new Date(c);
  7161. var u = d.includeAllIntervals;
  7162. var p = this.getCalendar();
  7163. var l = [];
  7164. var n = [];
  7165. var b = [];
  7166. this.forEachAssignment(function(k) {
  7167. var i = k.getTask();
  7168. if (i.getStartDate() > t || i.getEndDate() < c) {
  7169. return
  7170. }
  7171. n.push(i);
  7172. b.push(i.getCalendar());
  7173. l.push(k)
  7174. });
  7175. if (!n.length) {
  7176. return
  7177. }
  7178. var e = Sch.util.Date;
  7179. var y = [c - 0, t - 0];
  7180. var j = {};
  7181. j[c - 0] = [{
  7182. type : "00-intervalStart"
  7183. }];
  7184. j[t - 0] = [{
  7185. type : "00-intervalEnd"
  7186. }];
  7187. var s;
  7188. while (g < t) {
  7189. this.collectAvailabilityIntervalPoints(p
  7190. .getAvailabilityIntervalsFor(g), function() {
  7191. return {
  7192. type : "00-resourceAvailabilityStart"
  7193. }
  7194. }, function() {
  7195. return {
  7196. type : "01-resourceAvailabilityEnd"
  7197. }
  7198. }, j, y);
  7199. for (s = 0; s < b.length; s++) {
  7200. this.collectAvailabilityIntervalPoints(b[s]
  7201. .getAvailabilityIntervalsFor(g), function() {
  7202. return {
  7203. type : "02-taskAvailabilityStart",
  7204. assignment : l[s],
  7205. taskId : n[s].getInternalId(),
  7206. units : l[s].getUnits()
  7207. }
  7208. }, function() {
  7209. return {
  7210. type : "03-taskAvailabilityEnd",
  7211. taskId : n[s].getInternalId()
  7212. }
  7213. }, j, y)
  7214. }
  7215. g = e.getStartOfNextDay(g)
  7216. }
  7217. y.sort();
  7218. var v = false;
  7219. var w = {};
  7220. var m = 0;
  7221. for (s = 0; s < y.length - 1; s++) {
  7222. var r = j[y[s]];
  7223. r.sort(function(k, i) {
  7224. return k.type < i.type
  7225. });
  7226. for (var q = 0; q < r.length; q++) {
  7227. var o = r[q];
  7228. if (o.type == "00-resourceAvailabilityStart") {
  7229. v = true
  7230. }
  7231. if (o.type == "01-resourceAvailabilityEnd") {
  7232. v = false
  7233. }
  7234. if (o.type == "02-taskAvailabilityStart") {
  7235. w[o.taskId] = o;
  7236. m++
  7237. }
  7238. if (o.type == "03-taskAvailabilityEnd") {
  7239. delete w[o.taskId];
  7240. m--
  7241. }
  7242. }
  7243. if (u || v && m) {
  7244. var x = y[s];
  7245. var h = y[s + 1];
  7246. if (x > t || h < c) {
  7247. continue
  7248. }
  7249. if (x < c) {
  7250. x = c - 0
  7251. }
  7252. if (h > t) {
  7253. h = t - 0
  7254. }
  7255. if (f.call(a, x, h, w) === false) {
  7256. return false
  7257. }
  7258. }
  7259. }
  7260. },
  7261. getAllocationInfo : function(a) {
  7262. var b = [];
  7263. this.forEachAvailabilityIntervalWithTasks(a, function(h, g, f) {
  7264. var e = 0;
  7265. var c = [];
  7266. for (var d in f) {
  7267. e += f[d].units;
  7268. c.push(f[d].assignment)
  7269. }
  7270. b.push({
  7271. startDate : new Date(h),
  7272. endDate : new Date(g),
  7273. totalAllocation : e,
  7274. assignments : c
  7275. })
  7276. });
  7277. return b
  7278. }
  7279. });
  7280. Ext.define("Gnt.model.task.More", {
  7281. indent : function() {
  7282. var a = this.previousSibling;
  7283. if (a) {
  7284. this.isMove = true;
  7285. a.appendChild(this);
  7286. delete this.isMove;
  7287. a.set("leaf", false);
  7288. a.expand()
  7289. }
  7290. },
  7291. outdent : function() {
  7292. var a = this.parentNode;
  7293. if (a && !a.isRoot()) {
  7294. if (this.convertEmptyParentToLeaf) {
  7295. a.set("leaf", a.childNodes.length === 1)
  7296. }
  7297. this.isMove = true;
  7298. if (a.nextSibling) {
  7299. a.parentNode.insertBefore(this, a.nextSibling)
  7300. } else {
  7301. a.parentNode.appendChild(this)
  7302. }
  7303. delete this.isMove
  7304. }
  7305. },
  7306. getAllDependencies : function(a) {
  7307. a = a || this.getDependencyStore();
  7308. return a.getDependenciesForTask(this)
  7309. },
  7310. hasIncomingDependencies : function(a) {
  7311. var c = this.getId() || this.internalId;
  7312. a = a || this.getDependencyStore();
  7313. var b = a.findBy(function(d) {
  7314. return d.getTargetId() == c
  7315. });
  7316. return b >= 0
  7317. },
  7318. getIncomingDependencies : function(a) {
  7319. a = a || this.getDependencyStore();
  7320. return a.getIncomingDependenciesForTask(this)
  7321. },
  7322. getOutgoingDependencies : function(a) {
  7323. a = a || this.getDependencyStore();
  7324. return a.getOutgoingDependenciesForTask(this)
  7325. },
  7326. constrain : function(c) {
  7327. if (this.isManuallyScheduled()) {
  7328. return false
  7329. }
  7330. var e = false;
  7331. c = c || this.getTaskStore();
  7332. var b = this.getConstrainContext(c);
  7333. if (b) {
  7334. var a = b.startDate;
  7335. var d = b.endDate;
  7336. if (a && a - this.getStartDate() !== 0) {
  7337. this.setStartDate(a, true, c.skipWeekendsDuringDragDrop);
  7338. e = true
  7339. } else {
  7340. if (d && d - this.getEndDate() !== 0) {
  7341. this.setEndDate(d, true, c.skipWeekendsDuringDragDrop);
  7342. e = true
  7343. }
  7344. }
  7345. }
  7346. return e
  7347. },
  7348. getConstrainContext : function(f) {
  7349. var g = this.getIncomingDependencies();
  7350. if (!g.length) {
  7351. return null
  7352. }
  7353. var h = f || this.getTaskStore(), a = Gnt.model.Dependency.Type, c = new Date(0), b = new Date(0), i = Ext.Date, e = this
  7354. .getProjectCalendar(), d;
  7355. Ext.each(g, function(l) {
  7356. var k = l.getSourceTask();
  7357. if (k) {
  7358. var o = l.getLag() || 0, m = l.getLagUnit(), n = k
  7359. .getStartDate(), j = k.getEndDate();
  7360. switch (l.getType()) {
  7361. case a.StartToEnd :
  7362. n = e.skipWorkingTime(n, o, m);
  7363. if (b < n) {
  7364. b = n;
  7365. d = k
  7366. }
  7367. break;
  7368. case a.StartToStart :
  7369. n = e.skipWorkingTime(n, o, m);
  7370. if (c < n) {
  7371. c = n;
  7372. d = k
  7373. }
  7374. break;
  7375. case a.EndToStart :
  7376. j = e.skipWorkingTime(j, o, m);
  7377. if (c < j) {
  7378. c = j;
  7379. d = k
  7380. }
  7381. break;
  7382. case a.EndToEnd :
  7383. j = e.skipWorkingTime(j, o, m);
  7384. if (b < j) {
  7385. b = j;
  7386. d = k
  7387. }
  7388. break;
  7389. default :
  7390. throw "Invalid dependency type: " + l.getType()
  7391. }
  7392. }
  7393. });
  7394. return {
  7395. startDate : c > 0 ? c : null,
  7396. endDate : b > 0 ? b : null,
  7397. constrainingTask : d
  7398. }
  7399. },
  7400. getCriticalPaths : function() {
  7401. var b = [this], a = this.getConstrainContext();
  7402. while (a) {
  7403. b.push(a.constrainingTask);
  7404. a = a.constrainingTask.getConstrainContext()
  7405. }
  7406. return b
  7407. },
  7408. cascadeChanges : function(a, b, c) {
  7409. a = a || this.getTaskStore();
  7410. var d;
  7411. if (this.isLeaf()) {
  7412. d = this.constrain(a);
  7413. if (d) {
  7414. this.recalculateParents();
  7415. b.nbrAffected++
  7416. }
  7417. }
  7418. if (d) {
  7419. Ext.each(this.getOutgoingDependencies(), function(e) {
  7420. var f = e.getTargetTask();
  7421. if (f && !f.isManuallyScheduled()) {
  7422. f.cascadeChanges(a, b, e)
  7423. }
  7424. })
  7425. }
  7426. },
  7427. addSubtask : function(a) {
  7428. this.set("leaf", false);
  7429. this.appendChild(a);
  7430. this.expand();
  7431. return a
  7432. },
  7433. addSuccessor : function(b) {
  7434. var c = this.rec, e = this.getTaskStore(), d = this
  7435. .getDependencyStore();
  7436. b = b || new this.self();
  7437. b.calendar = b.calendar || this.getCalendar();
  7438. b.taskStore = e;
  7439. b.setStartDate(this.getEndDate(), true, e.skipWeekendsDuringDragDrop);
  7440. b.setDuration(1, Sch.util.Date.DAY);
  7441. this.addTaskBelow(b);
  7442. var a = new d.model({
  7443. fromTask : this,
  7444. toTask : b,
  7445. type : d.model.Type.EndToStart
  7446. });
  7447. d.add(a);
  7448. return b
  7449. },
  7450. addMilestone : function(c) {
  7451. var b = this.getTaskStore();
  7452. c = c || new this.self();
  7453. var a = this.getEndDate();
  7454. if (a) {
  7455. c.calendar = c.calendar || this.getCalendar();
  7456. c.setStartEndDate(a, a, b.skipWeekendsDuringDragDrop)
  7457. }
  7458. return this.addTaskBelow(c)
  7459. },
  7460. addPredecessor : function(c) {
  7461. var b = this.getDependencyStore();
  7462. c = c || new this.self();
  7463. c.calendar = c.calendar || this.getCalendar();
  7464. c.beginEdit();
  7465. c.set(this.startDateField, c.calculateStartDate(this.getStartDate(), 1,
  7466. Sch.util.Date.DAY));
  7467. c.set(this.endDateField, this.getStartDate());
  7468. c.set(this.durationField, 1);
  7469. c.set(this.durationUnitField, Sch.util.Date.DAY);
  7470. c.endEdit();
  7471. this.addTaskAbove(c);
  7472. var a = new b.model({
  7473. fromTask : c,
  7474. toTask : this,
  7475. type : b.model.Type.EndToStart
  7476. });
  7477. b.add(a);
  7478. return c
  7479. },
  7480. getSuccessors : function() {
  7481. var h = this.getId() || this.internalId;
  7482. var e = e || this.getDependencyStore();
  7483. var c = this.getTaskStore(), g = [];
  7484. for (var f = 0, a = e.getCount(); f < a; f++) {
  7485. var d = e.getAt(f);
  7486. if (d.getSourceId() == h) {
  7487. var b = d.getTargetTask();
  7488. if (b) {
  7489. g.push(b)
  7490. }
  7491. }
  7492. }
  7493. return g
  7494. },
  7495. getPredecessors : function() {
  7496. var g = this.getId() || this.internalId;
  7497. var d = d || this.getDependencyStore();
  7498. var b = this.getTaskStore(), f = [];
  7499. for (var e = 0, a = d.getCount(); e < a; e++) {
  7500. var c = d.getAt(e);
  7501. if (c.getTargetId() == g) {
  7502. f.push(c.getSourceTask())
  7503. }
  7504. }
  7505. return f
  7506. },
  7507. addTaskAbove : function(a) {
  7508. a = a || new this.self();
  7509. return this.parentNode.insertBefore(a, this)
  7510. },
  7511. addTaskBelow : function(a) {
  7512. a = a || new this.self();
  7513. if (this.nextSibling) {
  7514. return this.parentNode.insertBefore(a, this.nextSibling)
  7515. } else {
  7516. return this.parentNode.appendChild(a)
  7517. }
  7518. },
  7519. isAbove : function(a) {
  7520. var b = this, c = Math.min(b.data.depth, a.data.depth);
  7521. while (b.data.depth > c) {
  7522. b = b.parentNode
  7523. }
  7524. while (a.data.depth > c) {
  7525. a = a.parentNode
  7526. }
  7527. while (a.parentNode !== b.parentNode) {
  7528. a = a.parentNode;
  7529. b = b.parentNode
  7530. }
  7531. return a.data.index > b.data.index
  7532. },
  7533. cascadeChildren : function(a, c, b) {
  7534. this.cascadeBy(function(d) {
  7535. if (d !== a) {
  7536. return c.call(b || d, d)
  7537. }
  7538. })
  7539. }
  7540. });
  7541. Ext.define("Gnt.model.Task", {
  7542. extend : "Sch.model.Range",
  7543. requires : ["Sch.util.Date", "Ext.data.NodeInterface"],
  7544. mixins : ["Gnt.model.task.More"],
  7545. idProperty : "Id",
  7546. customizableFields : [{
  7547. name : "Id"
  7548. }, {
  7549. name : "Duration",
  7550. type : "number",
  7551. useNull : true
  7552. }, {
  7553. name : "Effort",
  7554. type : "number",
  7555. useNull : true
  7556. }, {
  7557. name : "EffortUnit",
  7558. type : "string",
  7559. defaultValue : "h"
  7560. }, {
  7561. name : "CalendarId",
  7562. type : "string"
  7563. }, {
  7564. name : "DurationUnit",
  7565. type : "string",
  7566. defaultValue : "d",
  7567. convert : function(a) {
  7568. return a || "d"
  7569. }
  7570. }, {
  7571. name : "PercentDone",
  7572. type : "int",
  7573. defaultValue : 0
  7574. }, {
  7575. name : "ManuallyScheduled",
  7576. type : "boolean",
  7577. defaultValue : false
  7578. }, {
  7579. name : "SchedulingMode",
  7580. type : "string",
  7581. defaultValue : "Normal"
  7582. }, {
  7583. name : "BaselineStartDate",
  7584. type : "date",
  7585. dateFormat : "c"
  7586. }, {
  7587. name : "BaselineEndDate",
  7588. type : "date",
  7589. dateFormat : "c"
  7590. }, {
  7591. name : "BaselinePercentDone",
  7592. type : "int",
  7593. defaultValue : 0
  7594. }, {
  7595. name : "Draggable",
  7596. type : "boolean",
  7597. persist : false,
  7598. defaultValue : true
  7599. }, {
  7600. name : "Resizable",
  7601. persist : false
  7602. }, {
  7603. name : "PhantomId",
  7604. type : "string"
  7605. }, {
  7606. name : "PhantomParentId",
  7607. type : "string"
  7608. }],
  7609. draggableField : "Draggable",
  7610. resizableField : "Resizable",
  7611. nameField : "Name",
  7612. durationField : "Duration",
  7613. durationUnitField : "DurationUnit",
  7614. effortField : "Effort",
  7615. effortUnitField : "EffortUnit",
  7616. percentDoneField : "PercentDone",
  7617. manuallyScheduledField : "ManuallyScheduled",
  7618. schedulingModeField : "SchedulingMode",
  7619. calendarIdField : "CalendarId",
  7620. baselineStartDateField : "BaselineStartDate",
  7621. baselineEndDateField : "BaselineEndDate",
  7622. baselinePercentDoneField : "BaselinePercentDone",
  7623. calendar : null,
  7624. dependencyStore : null,
  7625. taskStore : null,
  7626. phantomIdField : "PhantomId",
  7627. phantomParentIdField : "PhantomParentId",
  7628. normalized : false,
  7629. recognizedSchedulingModes : ["Normal", "Manual", "FixedDuration",
  7630. "EffortDriven", "DynamicAssignment"],
  7631. convertEmptyParentToLeaf : true,
  7632. constructor : function() {
  7633. this.getModifiedFieldNames = function() {
  7634. if (this.__isFilling__) {
  7635. return []
  7636. }
  7637. delete this.getModifiedFieldNames;
  7638. return this.getModifiedFieldNames.apply(this, arguments)
  7639. };
  7640. this.callParent(arguments);
  7641. if (this.phantom) {
  7642. this.data[this.phantomIdField] = this.internalId
  7643. }
  7644. },
  7645. normalize : function() {
  7646. var c = this.getDuration(), g = this.getDurationUnit(), b = this
  7647. .getStartDate(), f = this.getEndDate(), e = this
  7648. .getSchedulingMode(), d = this.data;
  7649. if (f && this.inclusiveEndDate) {
  7650. var i = this.fields.getByKey(this.endDateField).dateFormat;
  7651. var a = (i && !Ext.Date.formatContainsHourInfo(i))
  7652. || (f.getHours() === 0 && f.getMinutes() === 0
  7653. && f.getSeconds() === 0 && f.getMilliseconds() === 0);
  7654. if (a) {
  7655. if (Ext.isNumber(c)) {
  7656. f = d[this.endDateField] = this.calculateEndDate(b, c, g)
  7657. } else {
  7658. f = d[this.endDateField] = Ext.Date.add(f, Ext.Date.DAY, 1)
  7659. }
  7660. }
  7661. }
  7662. if (c == null && b && f) {
  7663. d[this.durationField] = this.calculateDuration(b, f, g)
  7664. }
  7665. if ((e == "Normal" || this.isManuallyScheduled()) && f == null && b
  7666. && Ext.isNumber(c)) {
  7667. d[this.endDateField] = this.calculateEndDate(b, c, g)
  7668. }
  7669. if (e == "EffortDriven" || e == "FixedDuration") {
  7670. var j = this.get(this.effortField), h = this.getEffortUnit();
  7671. if (j == null && b && f) {
  7672. d[this.effortField] = this.calculateEffort(b, f, h)
  7673. }
  7674. if (f == null && b && j) {
  7675. d[this.endDateField] = this.calculateEffortDrivenEndDate(b, j,
  7676. h);
  7677. if (c == null) {
  7678. d[this.durationField] = this.calculateDuration(b,
  7679. d[this.endDateField], g)
  7680. }
  7681. }
  7682. }
  7683. this.normalized = true
  7684. },
  7685. normalizeEffort : function() {
  7686. var c = this.childNodes;
  7687. var b = 0;
  7688. for (var a = 0; a < c.length; a++) {
  7689. var d = c[a];
  7690. if (!d.isLeaf()) {
  7691. d.normalizeEffort()
  7692. }
  7693. b += d.getEffort("MILLI")
  7694. }
  7695. if (this.getEffort("MILLI") != b) {
  7696. this.data[this.effortField] = this.getProjectCalendar()
  7697. .convertMSDurationToUnit(b, this.getEffortUnit())
  7698. }
  7699. },
  7700. getInternalId : function() {
  7701. return this.getId() || this.internalId
  7702. },
  7703. getCalendar : function(a) {
  7704. return a ? this.getOwnCalendar() : this.getOwnCalendar()
  7705. || this.getProjectCalendar()
  7706. },
  7707. getOwnCalendar : function() {
  7708. var a = this.get(this.calendarIdField);
  7709. return a ? Gnt.data.Calendar.getCalendar(a) : this.calendar
  7710. },
  7711. getProjectCalendar : function() {
  7712. var a = this.stores[0];
  7713. var b = a && a.getCalendar && a.getCalendar() || this.parentNode
  7714. && this.parentNode.getProjectCalendar() || this.isRoot()
  7715. && this.calendar;
  7716. if (!b) {
  7717. Ext.Error
  7718. .raise("Can't find a project calendar in `getProjectCalendar`")
  7719. }
  7720. return b
  7721. },
  7722. setCalendar : function(a) {
  7723. this.calendar = a
  7724. },
  7725. getDependencyStore : function() {
  7726. var a = this.dependencyStore || this.getTaskStore().dependencyStore;
  7727. if (!a) {
  7728. Ext.Error
  7729. .raise("Can't find a dependencyStore in `getDependencyStore`")
  7730. }
  7731. return a
  7732. },
  7733. getResourceStore : function() {
  7734. return this.getTaskStore().getResourceStore()
  7735. },
  7736. getAssignmentStore : function() {
  7737. return this.getTaskStore().getAssignmentStore()
  7738. },
  7739. getTaskStore : function(b) {
  7740. if (this.taskStore) {
  7741. return this.taskStore
  7742. }
  7743. var a = this.stores[0] && this.stores[0].taskStore || this.parentNode
  7744. && this.parentNode.getTaskStore(b);
  7745. if (!a && !b) {
  7746. Ext.Error.raise("Can't find a taskStore in `getTaskStore`")
  7747. }
  7748. return this.taskStore = a
  7749. },
  7750. isManuallyScheduled : function() {
  7751. return this.get(this.schedulingModeField) == "Manual"
  7752. || this.get(this.manuallyScheduledField)
  7753. },
  7754. setManuallyScheduled : function(a) {
  7755. if (a) {
  7756. this.set(this.schedulingModeField, "Manual")
  7757. } else {
  7758. if (this.get(this.schedulingModeField) == "Manual") {
  7759. this.set(this.schedulingModeField, "Normal")
  7760. }
  7761. }
  7762. return this.set(this.manuallyScheduledField, a)
  7763. },
  7764. setSchedulingMode : function(a) {
  7765. if (!Ext.Array.contains(this.recognizedSchedulingModes, a)) {
  7766. throw "Unrecognized scheduling mode: " + a
  7767. }
  7768. this.beginEdit();
  7769. this.set(this.schedulingModeField, a);
  7770. if (a === "FixedDuration") {
  7771. this.updateEffortBasedOnDuration()
  7772. }
  7773. if (a === "EffortDriven") {
  7774. this.updateDurationBasedOnEffort()
  7775. }
  7776. this.endEdit()
  7777. },
  7778. skipNonWorkingTime : function(b, c) {
  7779. var a = false;
  7780. this.forEachAvailabilityIntervalWithResources(c ? {
  7781. startDate : b
  7782. } : {
  7783. endDate : b,
  7784. isForward : false
  7785. }, function(f, e, d) {
  7786. b = c ? f : e;
  7787. a = true;
  7788. return false
  7789. });
  7790. return a ? new Date(b) : this.getCalendar().skipNonWorkingTime(b, c)
  7791. },
  7792. setStartDate : function(a, f, e) {
  7793. this.beginEdit();
  7794. if (!a) {
  7795. this.set(this.durationField, null);
  7796. this.set(this.startDateField, null)
  7797. } else {
  7798. var d = this.getCalendar();
  7799. if (e && !this.isManuallyScheduled()) {
  7800. if (!this.isMilestone() || d.isHoliday(a - 1)) {
  7801. a = this.skipNonWorkingTime(a, true)
  7802. }
  7803. }
  7804. var b = this.getSchedulingMode();
  7805. this.set(this.startDateField, a);
  7806. if (f !== false) {
  7807. if (b == "EffortDriven") {
  7808. this.set(this.endDateField, this
  7809. .calculateEffortDrivenEndDate(a, this
  7810. .getEffort()))
  7811. } else {
  7812. var c = this.getDuration();
  7813. if (Ext.isNumber(c)) {
  7814. this.set(this.endDateField, this.calculateEndDate(a, c,
  7815. this.getDurationUnit()))
  7816. }
  7817. }
  7818. } else {
  7819. if (this.getEndDate()) {
  7820. this.set(this.durationField, this.calculateDuration(a, this
  7821. .getEndDate(), this
  7822. .getDurationUnit()))
  7823. }
  7824. }
  7825. }
  7826. this.onPotentialEffortChange();
  7827. this.endEdit()
  7828. },
  7829. setEndDate : function(a, e, d) {
  7830. this.beginEdit();
  7831. if (!a) {
  7832. this.set(this.durationField, null);
  7833. this.set(this.endDateField, null)
  7834. } else {
  7835. var c = this.getCalendar();
  7836. if (d && !this.isManuallyScheduled()) {
  7837. a = this.skipNonWorkingTime(a, false)
  7838. }
  7839. if (e !== false) {
  7840. var b = this.getDuration();
  7841. if (Ext.isNumber(b)) {
  7842. this.set(this.startDateField, this.calculateStartDate(a, b,
  7843. this.getDurationUnit()));
  7844. this.set(this.endDateField, a)
  7845. } else {
  7846. this.set(this.endDateField, a)
  7847. }
  7848. } else {
  7849. this.set(this.endDateField, a);
  7850. if (this.getStartDate()) {
  7851. this.set(this.durationField, this.calculateDuration(this
  7852. .getStartDate(), a, this
  7853. .getDurationUnit()))
  7854. }
  7855. }
  7856. }
  7857. this.onPotentialEffortChange();
  7858. this.endEdit()
  7859. },
  7860. setStartEndDate : function(a, b, c) {
  7861. this.beginEdit();
  7862. if (c && !this.isManuallyScheduled()) {
  7863. a = a && this.skipNonWorkingTime(a, true);
  7864. b = b && this.skipNonWorkingTime(b, false)
  7865. }
  7866. this.set(this.startDateField, a);
  7867. this.set(this.endDateField, b);
  7868. this.set(this.durationField, this.calculateDuration(a, b, this
  7869. .getDurationUnit()));
  7870. this.onPotentialEffortChange();
  7871. this.endEdit()
  7872. },
  7873. getDuration : function(a) {
  7874. if (!a) {
  7875. return this.get(this.durationField)
  7876. }
  7877. var b = this.getProjectCalendar(), c = b.convertDurationToMs(this
  7878. .get(this.durationField), this
  7879. .get(this.durationUnitField));
  7880. return b.convertMSDurationToUnit(c, a)
  7881. },
  7882. getEffort : function(a) {
  7883. var b = this.get(this.effortField) || 0;
  7884. if (!a) {
  7885. return b
  7886. }
  7887. var c = this.getProjectCalendar(), d = c.convertDurationToMs(b, this
  7888. .getEffortUnit());
  7889. return c.convertMSDurationToUnit(d, a)
  7890. },
  7891. setEffort : function(b, a) {
  7892. a = a || this.get(this.effortUnitField);
  7893. this.beginEdit();
  7894. this.set(this.effortField, b);
  7895. this.set(this.effortUnitField, a);
  7896. if (this.getSchedulingMode() === "EffortDriven") {
  7897. this.updateDurationBasedOnEffort()
  7898. }
  7899. if (this.getSchedulingMode() === "DynamicAssignment") {
  7900. this.updateAssignments()
  7901. }
  7902. this.endEdit()
  7903. },
  7904. getCalendarDuration : function(a) {
  7905. return this.getProjectCalendar().convertMSDurationToUnit(
  7906. this.getEndDate() - this.getStartDate(),
  7907. a || this.get(this.durationUnitField))
  7908. },
  7909. setDuration : function(d, c) {
  7910. c = c || this.get(this.durationUnitField);
  7911. this.beginEdit();
  7912. if (Ext.isNumber(d) && !this.getStartDate()) {
  7913. var a = new Date();
  7914. Ext.Date.clearTime(a);
  7915. this.setStartDate(a)
  7916. }
  7917. var b = null;
  7918. if (Ext.isNumber(d)) {
  7919. b = this.calculateEndDate(this.getStartDate(), d, c)
  7920. }
  7921. this.set(this.endDateField, b);
  7922. this.set(this.durationField, d);
  7923. this.set(this.durationUnitField, c);
  7924. this.onPotentialEffortChange();
  7925. this.endEdit()
  7926. },
  7927. calculateStartDate : function(e, d, c) {
  7928. c = c || this.getDurationUnit();
  7929. if (this.isManuallyScheduled()) {
  7930. return Sch.util.Date.add(a, c, -d)
  7931. } else {
  7932. if (this.getTaskStore(true) && this.hasAssignments()) {
  7933. var b = this.getProjectCalendar().convertDurationToMs(d,
  7934. c || this.getDurationUnit());
  7935. var a;
  7936. this.forEachAvailabilityIntervalWithResources({
  7937. endDate : e,
  7938. isForward : false
  7939. }, function(i, h, g) {
  7940. var f = h - i;
  7941. if (f >= b) {
  7942. a = new Date(h - b);
  7943. return false
  7944. } else {
  7945. b -= f
  7946. }
  7947. });
  7948. return a
  7949. } else {
  7950. return this.getCalendar().calculateStartDate(e, d, c)
  7951. }
  7952. }
  7953. },
  7954. calculateEndDate : function(a, f, d) {
  7955. d = d || this.getDurationUnit();
  7956. if (this.isManuallyScheduled()) {
  7957. return Sch.util.Date.add(a, d, f)
  7958. } else {
  7959. var c = this.getSchedulingMode();
  7960. if (this.getTaskStore(true) && this.hasAssignments()
  7961. && c != "FixedDuration" && c != "DynamicAssignment"
  7962. && c != "EffortDriven") {
  7963. var b = this.getProjectCalendar().convertDurationToMs(f,
  7964. d || this.getDurationUnit());
  7965. var e;
  7966. this.forEachAvailabilityIntervalWithResources({
  7967. startDate : a
  7968. }, function(j, i, h) {
  7969. var g = i - j;
  7970. if (g >= b) {
  7971. e = new Date(j + b);
  7972. return false
  7973. } else {
  7974. b -= g
  7975. }
  7976. });
  7977. return e
  7978. } else {
  7979. return this.getCalendar().calculateEndDate(a, f, d)
  7980. }
  7981. }
  7982. },
  7983. calculateDuration : function(a, c, b) {
  7984. b = b || this.getDurationUnit();
  7985. if (!a || !c) {
  7986. return 0
  7987. }
  7988. if (this.isManuallyScheduled()) {
  7989. return this.getProjectCalendar().convertMSDurationToUnit(c - a, b)
  7990. } else {
  7991. if (this.getTaskStore(true) && this.hasAssignments()) {
  7992. var d = 0;
  7993. this.forEachAvailabilityIntervalWithResources({
  7994. startDate : a,
  7995. endDate : c
  7996. }, function(g, f, e) {
  7997. d += f - g
  7998. });
  7999. return this.getProjectCalendar().convertMSDurationToUnit(d, b)
  8000. } else {
  8001. return this.getCalendar().calculateDuration(a, c, b)
  8002. }
  8003. }
  8004. },
  8005. forEachAvailabilityIntervalWithResources : function(f, h, a) {
  8006. a = a || this;
  8007. var C = this;
  8008. var d = f.startDate;
  8009. var z = f.endDate;
  8010. var p = f.isForward !== false;
  8011. if (p ? !d : !z) {
  8012. throw new Error("At least `startDate` or `endDate` is required, depending from the `isForward` option")
  8013. }
  8014. var j = new Date(p ? d : z);
  8015. var b = f.includeEmptyIntervals;
  8016. var c = this.getOwnCalendar();
  8017. var G = Boolean(c);
  8018. var E = this.getProjectCalendar();
  8019. var A, v, r;
  8020. if (f.resources) {
  8021. A = f.resources;
  8022. r = [];
  8023. v = [];
  8024. Ext.each(A, function(i) {
  8025. v.push(i.getCalendar());
  8026. r.push(C.getAssignmentFor(i))
  8027. })
  8028. } else {
  8029. r = this.getAssignments();
  8030. if (!r.length) {
  8031. return
  8032. }
  8033. A = [];
  8034. v = [];
  8035. Ext.each(r, function(k) {
  8036. var i = k.getResource();
  8037. A.push(i);
  8038. v.push(i.getCalendar())
  8039. })
  8040. }
  8041. var g = Sch.util.Date;
  8042. var y, u, B, D, n;
  8043. var t = p ? !z : !d;
  8044. while (t || (p ? j < z : j > d)) {
  8045. var q = {};
  8046. var F = [];
  8047. if (G) {
  8048. var l = c.getAvailabilityIntervalsFor(j - (p ? 0 : 1));
  8049. for (u = 0; u < l.length; u++) {
  8050. B = l[u];
  8051. D = B.startDate - 0;
  8052. n = B.endDate - 0;
  8053. if (!q[D]) {
  8054. q[D] = [];
  8055. F.push(D)
  8056. }
  8057. q[D].push({
  8058. type : "00-taskAvailailabilityStart",
  8059. typeBackward : "01-taskAvailailabilityStart"
  8060. });
  8061. F.push(n);
  8062. q[n] = q[n] || [];
  8063. q[n].push({
  8064. type : "01-taskAvailailabilityEnd",
  8065. typeBackward : "00-taskAvailailabilityEnd"
  8066. })
  8067. }
  8068. }
  8069. for (y = 0; y < v.length; y++) {
  8070. var e = v[y].getAvailabilityIntervalsFor(j);
  8071. for (u = 0; u < e.length; u++) {
  8072. B = e[u];
  8073. D = B.startDate - 0;
  8074. n = B.endDate - 0;
  8075. if (!q[D]) {
  8076. q[D] = [];
  8077. F.push(D)
  8078. }
  8079. q[D].push({
  8080. type : "02-resourceAvailailabilityStart",
  8081. typeBackward : "03-resourceAvailailabilityStart",
  8082. assignment : r[y],
  8083. resourceId : A[y].getInternalId(),
  8084. units : r[y].getUnits()
  8085. });
  8086. if (!q[n]) {
  8087. q[n] = [];
  8088. F.push(n)
  8089. }
  8090. q[n].push({
  8091. type : "03-resourceAvailailabilityEnd",
  8092. typeBackward : "02-resourceAvailailabilityEnd",
  8093. assignment : r[y],
  8094. resourceId : A[y].getInternalId(),
  8095. units : r[y].getUnits()
  8096. })
  8097. }
  8098. }
  8099. F.sort();
  8100. var x = false;
  8101. var o = {};
  8102. var m = 0;
  8103. var w, s;
  8104. if (p) {
  8105. for (y = 0; y < F.length; y++) {
  8106. w = q[F[y]];
  8107. w.sort(function(k, i) {
  8108. return k.type < i.type
  8109. });
  8110. for (u = 0; u < w.length; u++) {
  8111. s = w[u];
  8112. if (s.type == "00-taskAvailailabilityStart") {
  8113. x = true
  8114. }
  8115. if (s.type == "01-taskAvailailabilityEnd") {
  8116. x = false
  8117. }
  8118. if (s.type == "02-resourceAvailailabilityStart") {
  8119. o[s.resourceId] = s;
  8120. m++
  8121. }
  8122. if (s.type == "03-resourceAvailailabilityEnd") {
  8123. delete o[s.resourceId];
  8124. m--
  8125. }
  8126. }
  8127. if ((x || !G) && (m || b)) {
  8128. D = F[y];
  8129. n = F[y + 1];
  8130. if (D >= z || n <= d) {
  8131. continue
  8132. }
  8133. if (D < d) {
  8134. D = d - 0
  8135. }
  8136. if (n > z) {
  8137. n = z - 0
  8138. }
  8139. if (h.call(a, D, n, o) === false) {
  8140. return false
  8141. }
  8142. }
  8143. }
  8144. } else {
  8145. for (y = F.length - 1; y >= 0; y--) {
  8146. w = q[F[y]];
  8147. w.sort(function(k, i) {
  8148. return k.typeBackward < i.typeBackward
  8149. });
  8150. for (u = 0; u < w.length; u++) {
  8151. s = w[u];
  8152. if (s.typeBackward == "00-taskAvailailabilityEnd") {
  8153. x = true
  8154. }
  8155. if (s.typeBackward == "01-taskAvailailabilityStart") {
  8156. x = false
  8157. }
  8158. if (s.typeBackward == "02-resourceAvailailabilityEnd") {
  8159. o[s.resourceId] = s;
  8160. m++
  8161. }
  8162. if (s.typeBackward == "03-resourceAvailailabilityStart") {
  8163. delete o[s.resourceId];
  8164. m--
  8165. }
  8166. }
  8167. if ((x || !G) && (m || b)) {
  8168. D = F[y - 1];
  8169. n = F[y];
  8170. if (D > z || n <= d) {
  8171. continue
  8172. }
  8173. if (D < d) {
  8174. D = d - 0
  8175. }
  8176. if (n > z) {
  8177. n = z - 0
  8178. }
  8179. if (h.call(a, D, n, o) === false) {
  8180. return false
  8181. }
  8182. }
  8183. }
  8184. }
  8185. j = p ? g.getStartOfNextDay(j) : g.getEndOfPreviousDay(j)
  8186. }
  8187. },
  8188. calculateEffortDrivenEndDate : function(a, c, b) {
  8189. var e = this.getProjectCalendar().convertDurationToMs(c,
  8190. b || this.getEffortUnit());
  8191. var d = new Date(a);
  8192. this.forEachAvailabilityIntervalWithResources({
  8193. startDate : a
  8194. }, function(l, k, j) {
  8195. var m = 0;
  8196. for (var h in j) {
  8197. m += j[h].units
  8198. }
  8199. var g = k - l;
  8200. var f = m * g / 100;
  8201. if (f >= e) {
  8202. d = new Date(l + e / f * g);
  8203. return false
  8204. } else {
  8205. e -= f
  8206. }
  8207. });
  8208. return d
  8209. },
  8210. recalculateParents : function() {
  8211. var h = new Date(9999, 0, 0), e = new Date(0), m = this.parentNode;
  8212. if (m && m.childNodes.length > 0) {
  8213. var b = 0;
  8214. for (var f = 0, j = m.childNodes.length; f < j; f++) {
  8215. b += m.childNodes[f].getEffort("MILLI")
  8216. }
  8217. if (m.getEffort("MILLI") != b) {
  8218. m.setEffort(this.getProjectCalendar().convertMSDurationToUnit(
  8219. b, m.getEffortUnit()))
  8220. }
  8221. }
  8222. var n, c;
  8223. if (m && !m.isRoot() && m.childNodes.length > 0) {
  8224. if (!m.isManuallyScheduled()) {
  8225. for (var g = 0, d = m.childNodes.length; g < d; g++) {
  8226. var a = m.childNodes[g];
  8227. h = Sch.util.Date.min(h, a.getStartDate() || h);
  8228. e = Sch.util.Date.max(e, a.getEndDate() || e)
  8229. }
  8230. n = h - new Date(9999, 0, 0) !== 0
  8231. && m.getStartDate() - h !== 0;
  8232. c = e - new Date(0) !== 0 && m.getEndDate() - e !== 0;
  8233. if (n && c) {
  8234. m.setStartEndDate(h, e, false)
  8235. } else {
  8236. if (n) {
  8237. m.setStartDate(h, c, false)
  8238. } else {
  8239. if (c) {
  8240. m.setEndDate(e, false, false)
  8241. }
  8242. }
  8243. }
  8244. }
  8245. if (!n && !c) {
  8246. m.recalculateParents()
  8247. }
  8248. }
  8249. },
  8250. isMilestone : function() {
  8251. return this.getDuration() === 0
  8252. },
  8253. isBaselineMilestone : function() {
  8254. var b = this.getBaselineStartDate(), a = this.getBaselineEndDate();
  8255. if (b && a) {
  8256. return a - b === 0
  8257. }
  8258. return false
  8259. },
  8260. afterEdit : function(b) {
  8261. if (this.stores.length > 0 || !this.normalized) {
  8262. this.callParent(arguments)
  8263. } else {
  8264. var a = this.taskStore || this.getTaskStore(true);
  8265. if (a && !a.isFillingRoot) {
  8266. a.afterEdit(this, b)
  8267. }
  8268. this.callParent(arguments)
  8269. }
  8270. },
  8271. afterCommit : function() {
  8272. this.callParent(arguments);
  8273. if (this.stores.length > 0 || !this.normalized) {
  8274. return
  8275. }
  8276. var a = this.taskStore || this.getTaskStore(true);
  8277. if (a && !a.isFillingRoot) {
  8278. a.afterCommit(this)
  8279. }
  8280. },
  8281. afterReject : function() {
  8282. if (this.stores.length > 0) {
  8283. this.callParent(arguments)
  8284. } else {
  8285. var a = this.getTaskStore(true);
  8286. if (a && !a.isFillingRoot) {
  8287. a.afterReject(this)
  8288. }
  8289. this.callParent(arguments)
  8290. }
  8291. },
  8292. getDurationUnit : function() {
  8293. return this.get(this.durationUnitField) || "d"
  8294. },
  8295. getEffortUnit : function() {
  8296. return this.get(this.effortUnitField) || "h"
  8297. },
  8298. getBaselinePercentDone : function() {
  8299. return this.get(this.baselinePercentDoneField) || 0
  8300. },
  8301. isPersistable : function() {
  8302. var a = this.parentNode;
  8303. return !a.phantom
  8304. },
  8305. getResources : function() {
  8306. var b = this.getAssignmentStore(), c = this.getInternalId();
  8307. var a = [];
  8308. if (b) {
  8309. b.each(function(d) {
  8310. if (d.getTaskId() == c) {
  8311. a.push(d.getResource())
  8312. }
  8313. })
  8314. }
  8315. return a
  8316. },
  8317. getAssignments : function() {
  8318. var b = this.getAssignmentStore(), c = this.getInternalId();
  8319. var a = [];
  8320. if (b) {
  8321. b.each(function(d) {
  8322. if (d.getTaskId() == c) {
  8323. a.push(d)
  8324. }
  8325. })
  8326. }
  8327. return a
  8328. },
  8329. hasAssignments : function() {
  8330. var b = this.getAssignmentStore(), c = this.getInternalId();
  8331. var a = false;
  8332. if (b) {
  8333. b.each(function(d) {
  8334. if (d.getTaskId() == c) {
  8335. a = true;
  8336. return false
  8337. }
  8338. })
  8339. }
  8340. return a
  8341. },
  8342. getAssignmentFor : function(b) {
  8343. var c = this.getAssignmentStore(), e = this.getInternalId(), d = b instanceof Gnt.model.Resource
  8344. ? b.getInternalId()
  8345. : b;
  8346. var a;
  8347. if (c) {
  8348. c.each(function(f) {
  8349. if (f.getTaskId() == e && f.getResourceId() == d) {
  8350. a = f;
  8351. return false
  8352. }
  8353. })
  8354. }
  8355. return a || null
  8356. },
  8357. unassign : function() {
  8358. return this.unAssign.apply(this, arguments)
  8359. },
  8360. unAssign : function(c) {
  8361. var d = this.getAssignmentStore();
  8362. var b = this.getInternalId();
  8363. var e = c instanceof Gnt.model.Resource ? c.getInternalId() : c;
  8364. var a = d.findBy(function(f) {
  8365. return f.getResourceId() == e && f.getTaskId() == b
  8366. });
  8367. if (a >= 0) {
  8368. d.removeAt(a)
  8369. }
  8370. },
  8371. assign : function(e, a) {
  8372. var b = this.getTaskStore(), h = this.getInternalId(), f = b
  8373. .getAssignmentStore(), d = b.getResourceStore();
  8374. var g = e instanceof Gnt.model.Resource ? e.getInternalId() : e;
  8375. f.each(function(i) {
  8376. if (i.getTaskId() == h && i.getResourceId() == g) {
  8377. throw "Resource can't be assigned twice to the same task"
  8378. }
  8379. });
  8380. if (e instanceof Gnt.model.Resource && d.indexOf(e) == -1) {
  8381. d.add(e)
  8382. }
  8383. var c = new Gnt.model.Assignment({
  8384. TaskId : h,
  8385. ResourceId : g,
  8386. Units : a
  8387. });
  8388. f.add(c);
  8389. return c
  8390. },
  8391. calculateEffort : function(a, c, b) {
  8392. var d = 0;
  8393. this.forEachAvailabilityIntervalWithResources({
  8394. startDate : a,
  8395. endDate : c
  8396. }, function(h, g, f) {
  8397. var j = 0;
  8398. for (var e in f) {
  8399. j += f[e].units
  8400. }
  8401. d += (g - h) * j / 100
  8402. });
  8403. return this.getProjectCalendar().convertMSDurationToUnit(d,
  8404. b || this.getEffortUnit())
  8405. },
  8406. updateAssignments : function() {
  8407. var b = {};
  8408. var a = this.getStartDate();
  8409. var d = this.getEndDate();
  8410. var c = 0;
  8411. this.forEachAvailabilityIntervalWithResources({
  8412. startDate : a,
  8413. endDate : d
  8414. }, function(h, g, f) {
  8415. for (var i in f) {
  8416. c += g - h
  8417. }
  8418. });
  8419. if (!c) {
  8420. return
  8421. }
  8422. var e = this.getEffort(Sch.util.Date.MILLI);
  8423. Ext.Array.each(this.getAssignments(), function(f) {
  8424. f.setUnits(e / c * 100)
  8425. })
  8426. },
  8427. updateEffortBasedOnDuration : function() {
  8428. this.setEffort(this.calculateEffort(this.getStartDate(), this
  8429. .getEndDate()))
  8430. },
  8431. updateDurationBasedOnEffort : function() {
  8432. this.setEndDate(this.calculateEffortDrivenEndDate(this.getStartDate(),
  8433. this.getEffort(), this.getEffortUnit()), false)
  8434. },
  8435. onPotentialEffortChange : function() {
  8436. if (this.getSchedulingMode() === "FixedDuration") {
  8437. this.updateEffortBasedOnDuration()
  8438. }
  8439. if (this.getSchedulingMode() === "DynamicAssignment") {
  8440. this.updateAssignments()
  8441. }
  8442. },
  8443. onAssignmentMutation : function() {
  8444. if (this.getSchedulingMode() === "FixedDuration") {
  8445. this.updateEffortBasedOnDuration()
  8446. }
  8447. if (this.getSchedulingMode() === "EffortDriven") {
  8448. this.updateDurationBasedOnEffort()
  8449. }
  8450. },
  8451. onAssignmentStructureMutation : function() {
  8452. if (this.getSchedulingMode() == "FixedDuration") {
  8453. this.updateEffortBasedOnDuration()
  8454. }
  8455. if (this.getSchedulingMode() === "EffortDriven") {
  8456. this.updateDurationBasedOnEffort()
  8457. }
  8458. if (this.getSchedulingMode() === "DynamicAssignment") {
  8459. this.updateAssignments()
  8460. }
  8461. },
  8462. adjustToCalendar : function() {
  8463. if (this.get("leaf") && !this.isManuallyScheduled()) {
  8464. var a = this.hasIncomingDependencies();
  8465. if (a) {
  8466. this.constrain()
  8467. } else {
  8468. this.setStartDate(this.getStartDate(), true, true)
  8469. }
  8470. }
  8471. },
  8472. isEditable : function(a) {
  8473. if ((a === this.durationField || a === this.endDateField)
  8474. && this.getSchedulingMode() === "EffortDriven") {
  8475. return false
  8476. }
  8477. if (a === this.effortField
  8478. && this.getSchedulingMode() === "FixedDuration") {
  8479. return false
  8480. }
  8481. return true
  8482. },
  8483. isDraggable : function() {
  8484. return this.getDraggable()
  8485. },
  8486. isResizable : function() {
  8487. return this.getResizable()
  8488. },
  8489. ensureSingleSyncForMethod : function() {
  8490. return function() {
  8491. var a = this.getTaskStore(true);
  8492. var c;
  8493. if (a && a.autoSync && !a.autoSyncSuspended) {
  8494. c = true;
  8495. a.suspendAutoSync()
  8496. }
  8497. var b = this.callParent(arguments);
  8498. if (c) {
  8499. a.resumeAutoSync();
  8500. a.sync()
  8501. }
  8502. return b
  8503. }
  8504. },
  8505. getId : function() {
  8506. var a = this.data[this.idProperty];
  8507. return a && a !== "root" ? a : null
  8508. },
  8509. join : function(b) {
  8510. var a = this.store;
  8511. if (Ext.getVersion("extjs").isGreaterThanOrEqual("4.1.3") && a) {
  8512. if (b instanceof Ext.data.TreeStore && a.treeStore == b) {
  8513. return
  8514. }
  8515. if (b instanceof Ext.data.NodeStore && b.treeStore == a) {
  8516. this.unjoin(a)
  8517. }
  8518. }
  8519. this.callParent(arguments)
  8520. }
  8521. }, function() {
  8522. Ext.data.NodeInterface.decorate(this);
  8523. var a = ["addPredecessor", "addSubtask", "addSuccessor", "indent",
  8524. "outdent", "remove", "insertBefore", "appendChild"];
  8525. this.override({
  8526. remove : function() {
  8527. var b = this.parentNode;
  8528. var c = this.callParent(arguments);
  8529. if (b.convertEmptyParentToLeaf && b.childNodes.length === 0
  8530. && this.getTaskStore().recalculateParents) {
  8531. b.set("leaf", true)
  8532. }
  8533. return c
  8534. },
  8535. insertBefore : function(b) {
  8536. if (this.phantom) {
  8537. this.data[this.phantomIdField] = b.data[this.phantomParentIdField] = this.internalId
  8538. }
  8539. return this.callParent(arguments)
  8540. },
  8541. appendChild : function(b) {
  8542. if (this.phantom) {
  8543. this.data[this.phantomIdField] = b.data[this.phantomParentIdField] = this.internalId
  8544. }
  8545. return this.callParent(arguments)
  8546. }
  8547. });
  8548. Ext.each(a, function(c) {
  8549. var b = {};
  8550. b[c] = this.prototype
  8551. .ensureSingleSyncForMethod(this.prototype[c]);
  8552. this.override(b)
  8553. }, this)
  8554. });
  8555. Ext.define("Gnt.util.DurationParser", {
  8556. requires : ["Sch.util.Date"],
  8557. parseNumberFn : null,
  8558. durationRegex : null,
  8559. allowDecimals : true,
  8560. unitsRegex : {
  8561. MILLI : /^ms$|^mil/i,
  8562. SECOND : /^s$|^sec/i,
  8563. MINUTE : /^m$|^min/i,
  8564. HOUR : /^h$|^hr$|^hour/i,
  8565. DAY : /^d$|^day/i,
  8566. WEEK : /^w$|^wk|^week/i,
  8567. MONTH : /^mo|^mnt/i,
  8568. QUARTER : /^q$|^quar|^qrt/i,
  8569. YEAR : /^y$|^yr|^year/i
  8570. },
  8571. constructor : function(a) {
  8572. Ext.apply(this, a);
  8573. if (!this.durationRegex) {
  8574. this.durationRegex = this.allowDecimals
  8575. ? /^\s*([\-+]?\d+(?:[.,]\d+)?)\s*(\w+)?/i
  8576. : /^\s*([\-+]?\d+)(?![.,])\s*(\w+)?/i
  8577. }
  8578. },
  8579. parse : function(c) {
  8580. var a = this.durationRegex.exec(c);
  8581. if (c == null || !a) {
  8582. return null
  8583. }
  8584. var e = this.parseNumberFn(a[1]);
  8585. var b = a[2];
  8586. var d;
  8587. if (b) {
  8588. Ext.iterate(this.unitsRegex, function(f, g) {
  8589. if (g.test(b)) {
  8590. d = Sch.util.Date.getUnitByName(f);
  8591. return false
  8592. }
  8593. });
  8594. if (!d) {
  8595. return null
  8596. }
  8597. }
  8598. return {
  8599. value : e,
  8600. unit : d
  8601. }
  8602. }
  8603. });
  8604. Ext.define("Gnt.util.DependencyParser", {
  8605. requires : ["Gnt.util.DurationParser"],
  8606. separator : ";",
  8607. parseNumberFn : null,
  8608. dependencyRegex : /(-?\d+)(SS|SF|FS|FF)?([\+\-])?/i,
  8609. types : ["SS", "SF", "FS", "FF"],
  8610. constructor : function(a) {
  8611. this.durationParser = new Gnt.util.DurationParser(a);
  8612. Ext.apply(this, a)
  8613. },
  8614. parse : function(g) {
  8615. if (!g) {
  8616. return []
  8617. }
  8618. var c = g.split(this.separator);
  8619. var j = [];
  8620. var b = this.dependencyRegex;
  8621. for (var e = 0; e < c.length; e++) {
  8622. var f = b.exec(c[e]);
  8623. var d = {};
  8624. if (!f) {
  8625. return null
  8626. }
  8627. d.taskId = parseInt(f[1], 10);
  8628. if (!f[2] && f[3]) {
  8629. return null
  8630. }
  8631. d.type = this.types.indexOf((f[2] || "FS").toUpperCase());
  8632. var h = f[3];
  8633. if (h) {
  8634. var a = this.durationParser.parse(c[e].substring(c[e]
  8635. .indexOf(h)));
  8636. if (!a) {
  8637. return null
  8638. }
  8639. d.lag = a.value;
  8640. d.lagUnit = a.unit || "d"
  8641. }
  8642. j.push(d)
  8643. }
  8644. return j
  8645. }
  8646. });
  8647. Ext.define("Gnt.data.Calendar", {
  8648. extend : "Ext.data.Store",
  8649. requires : ["Ext.Date", "Gnt.model.CalendarDay", "Sch.model.Range",
  8650. "Sch.util.Date"],
  8651. model : "Gnt.model.CalendarDay",
  8652. daysPerMonth : 30,
  8653. daysPerWeek : 7,
  8654. hoursPerDay : 24,
  8655. unitsInMs : null,
  8656. defaultNonWorkingTimeCssCls : "gnt-holiday",
  8657. weekendsAreWorkdays : false,
  8658. weekendFirstDay : 6,
  8659. weekendSecondDay : 0,
  8660. holidaysCache : null,
  8661. availabilityIntervalsCache : null,
  8662. weekAvailability : null,
  8663. defaultWeekAvailability : null,
  8664. nonStandardWeeksByStartDate : null,
  8665. nonStandardWeeksStartDates : null,
  8666. calendarId : null,
  8667. parent : null,
  8668. defaultAvailability : ["00:00-24:00"],
  8669. name : null,
  8670. statics : {
  8671. getCalendar : function(a) {
  8672. if (a instanceof Gnt.data.Calendar) {
  8673. return a
  8674. }
  8675. return Ext.data.StoreManager.lookup("GNT_CALENDAR:" + a)
  8676. },
  8677. getAllCalendars : function() {
  8678. var a = [];
  8679. Ext.data.StoreManager.each(function(b) {
  8680. if (b instanceof Gnt.data.Calendar) {
  8681. a.push(b)
  8682. }
  8683. });
  8684. return a
  8685. }
  8686. },
  8687. constructor : function(a) {
  8688. a = a || {};
  8689. if (a.calendarId) {
  8690. this.storeId = "GNT_CALENDAR:" + a.calendarId
  8691. }
  8692. this.callParent(arguments);
  8693. var c = this;
  8694. var b = this.parent = Gnt.data.Calendar.getCalendar(a.parent);
  8695. if (a.parent && !this.parent) {
  8696. throw new Error("Invalid parent specified for calendar")
  8697. }
  8698. this.unitsInMs = {
  8699. MILLI : 1,
  8700. SECOND : 1000,
  8701. MINUTE : 60 * 1000,
  8702. HOUR : 60 * 60 * 1000,
  8703. DAY : this.hoursPerDay * 60 * 60 * 1000,
  8704. WEEK : this.daysPerWeek * this.hoursPerDay * 60 * 60 * 1000,
  8705. MONTH : this.daysPerMonth * this.hoursPerDay * 60 * 60 * 1000,
  8706. QUARTER : 3 * this.daysPerMonth * 24 * 60 * 60 * 1000,
  8707. YEAR : 4 * 3 * this.daysPerMonth * 24 * 60 * 60 * 1000
  8708. };
  8709. this.defaultWeekAvailability = this
  8710. .getDefaultWeekAvailability(this.weekendsAreWorkdays);
  8711. Ext.Array.each(a.weekAvailability || [], function(e, d) {
  8712. if (e) {
  8713. e.setDate(new Date(0, 0, d));
  8714. e.set(e.idProperty, "WEEKDAY:" + d)
  8715. }
  8716. c.add(e)
  8717. });
  8718. this.holidaysCache = {};
  8719. this.availabilityIntervalsCache = {};
  8720. this.on({
  8721. clear : this.clearCache,
  8722. datachanged : this.clearCache,
  8723. update : this.clearCache,
  8724. load : this.updateAvailability,
  8725. scope : this
  8726. });
  8727. b && b.on("clearcache", this.clearCache, this);
  8728. this.updateAvailability()
  8729. },
  8730. getDefaultWeekAvailability : function(f) {
  8731. if (arguments.length === 0) {
  8732. f = this.weekendsAreWorkdays
  8733. }
  8734. var e = this.defaultAvailability;
  8735. var d = this.weekendFirstDay;
  8736. var a = this.weekendSecondDay;
  8737. var c = [];
  8738. for (var b = 0; b < 7; b++) {
  8739. c.push(f || b != d && b != a ? new Gnt.model.CalendarDay({
  8740. Availability : Ext.Array.clone(e),
  8741. IsWorkingDay : true
  8742. }) : new Gnt.model.CalendarDay({
  8743. Availability : []
  8744. }))
  8745. }
  8746. return c
  8747. },
  8748. updateAvailability : function() {
  8749. var a = this.weekAvailability = [];
  8750. var c = this.nonStandardWeeksStartDates = [];
  8751. var b = this.nonStandardWeeksByStartDate = {};
  8752. this.each(function(e) {
  8753. var i = e.getId();
  8754. var g = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
  8755. .exec(i);
  8756. var f;
  8757. if (g) {
  8758. var d = Ext.Date.parse(g[2], "Y/m/d") - 0;
  8759. var h = Ext.Date.parse(g[3], "Y/m/d") - 0;
  8760. f = g[1];
  8761. if (!b[d]) {
  8762. b[d] = {
  8763. startDate : new Date(d),
  8764. endDate : new Date(h),
  8765. name : e.getName(),
  8766. weekAvailability : []
  8767. };
  8768. c.push(d)
  8769. }
  8770. b[d].weekAvailability[f] = e
  8771. }
  8772. g = /^WEEKDAY:(\d+)$/.exec(i);
  8773. if (g) {
  8774. f = g[1];
  8775. if (f < 0 || f > 6) {
  8776. throw new Error("Incorrect week day index")
  8777. }
  8778. a[f] = e
  8779. }
  8780. });
  8781. c.sort()
  8782. },
  8783. intersectsWithCurrentWeeks : function(b, d) {
  8784. var e = this.nonStandardWeeksStartDates;
  8785. var c = this.nonStandardWeeksByStartDate;
  8786. var a = false;
  8787. Ext.Array.each(e, function(h) {
  8788. var f = c[h].startDate;
  8789. var g = c[h].endDate;
  8790. if (f <= b && b < g || f < d && d <= g) {
  8791. a = true;
  8792. return false
  8793. }
  8794. });
  8795. return a
  8796. },
  8797. addNonStandardWeek : function(b, c, a) {
  8798. b = Ext.Date.clearTime(new Date(b));
  8799. c = Ext.Date.clearTime(new Date(c));
  8800. if (this.intersectsWithCurrentWeeks(b, c)) {
  8801. throw new Error("Can not add intersecting week")
  8802. }
  8803. Ext.Array.each(a, function(d, e) {
  8804. if (d) {
  8805. d.set(d.idProperty, e + "-"
  8806. + Ext.Date.format(b, "Y/m/d") + "-"
  8807. + Ext.Date.format(c, "Y/m/d"))
  8808. }
  8809. });
  8810. b = b - 0;
  8811. c = c - 0;
  8812. this.nonStandardWeeksStartDates.push(b);
  8813. this.nonStandardWeeksStartDates.sort();
  8814. this.nonStandardWeeksByStartDate[b] = {
  8815. startDate : new Date(b),
  8816. endDate : new Date(c),
  8817. weekAvailability : a
  8818. };
  8819. this.add(Ext.Array.clean(a))
  8820. },
  8821. getNonStandardWeekByStartDate : function(a) {
  8822. return this.nonStandardWeeksByStartDate[Ext.Date.clearTime(new Date(a))
  8823. - 0]
  8824. },
  8825. getNonStandardWeekByDate : function(d) {
  8826. d = Ext.Date.clearTime(new Date(d)) - 0;
  8827. var e = this.nonStandardWeeksStartDates;
  8828. var a = this.nonStandardWeeksByStartDate;
  8829. for (var c = 0; c < e.length; c++) {
  8830. var b = a[e[c]];
  8831. if (b.startDate <= d && d <= b.endDate) {
  8832. return b
  8833. }
  8834. }
  8835. return null
  8836. },
  8837. removeNonStandardWeek : function(a) {
  8838. a = Ext.Date.clearTime(new Date(a)) - 0;
  8839. var b = this.getNonStandardWeekByStartDate(a);
  8840. if (!b) {
  8841. return
  8842. }
  8843. this.remove(Ext.Array.clean(b.weekAvailability));
  8844. delete this.nonStandardWeeksByStartDate[a];
  8845. Ext.Array.remove(this.nonStandardWeeksStartDates, a)
  8846. },
  8847. clearCache : function() {
  8848. this.holidaysCache = {};
  8849. this.availabilityIntervalsCache = {};
  8850. this.fireEvent("clearcache", this)
  8851. },
  8852. setWeekendsAreWorkDays : function(a) {
  8853. if (a !== this.weekendsAreWorkdays) {
  8854. this.weekendsAreWorkdays = a;
  8855. this.clearCache();
  8856. this.defaultWeekAvailability = this
  8857. .getDefaultWeekAvailability(this.weekendsAreWorkdays)
  8858. }
  8859. },
  8860. areWeekendsWorkDays : function() {
  8861. return this.weekendsAreWorkdays
  8862. },
  8863. getCalendarDay : function(b) {
  8864. b = typeof b == "number" ? new Date(b) : b;
  8865. var a = this.getOverrideDay(b);
  8866. if (a) {
  8867. return a
  8868. }
  8869. return this.getDefaultCalendarDay(b.getDay(), b)
  8870. },
  8871. getOverrideDay : function(a) {
  8872. var b = this.getOwnCalendarDay(a);
  8873. if (b) {
  8874. return b
  8875. }
  8876. if (this.parent) {
  8877. return this.parent.getOverrideDay(a)
  8878. }
  8879. return null
  8880. },
  8881. getOwnCalendarDay : function(a) {
  8882. a = typeof a == "number" ? new Date(a) : a;
  8883. return this.getById(Ext.Date.clearTime(a, true) - 0)
  8884. },
  8885. getDefaultCalendarDay : function(c, b) {
  8886. if (b) {
  8887. var a = this.getNonStandardWeekByDate(b);
  8888. if (a && a.weekAvailability[c]) {
  8889. return a.weekAvailability[c]
  8890. }
  8891. }
  8892. if (this.weekAvailability[c]) {
  8893. return this.weekAvailability[c]
  8894. }
  8895. if (this.parent) {
  8896. return this.parent.getDefaultCalendarDay(c)
  8897. }
  8898. return this.defaultWeekAvailability[c]
  8899. },
  8900. isHoliday : function(c) {
  8901. var b = c - 0;
  8902. var d = this.holidaysCache;
  8903. if (d[b] != null) {
  8904. return d[b]
  8905. }
  8906. c = typeof c == "number" ? new Date(c) : c;
  8907. var a = this.getCalendarDay(c);
  8908. if (!a) {
  8909. throw "Can't find day for " + c
  8910. }
  8911. return d[b] = !a.getIsWorkingDay()
  8912. },
  8913. isWeekend : function(b) {
  8914. var a = b.getDay();
  8915. return a === this.weekendFirstDay || a === this.weekendSecondDay
  8916. },
  8917. isWorkingDay : function(a) {
  8918. return !this.isHoliday(a)
  8919. },
  8920. convertMSDurationToUnit : function(a, b) {
  8921. return a / this.unitsInMs[Sch.util.Date.getNameOfUnit(b)]
  8922. },
  8923. convertDurationToMs : function(b, a) {
  8924. return b * this.unitsInMs[Sch.util.Date.getNameOfUnit(a)]
  8925. },
  8926. getHolidaysRanges : function(d, g, a) {
  8927. if (d > g) {
  8928. Ext.Error.raise("startDate can't be bigger than endDate")
  8929. }
  8930. d = Ext.Date.clearTime(d, true);
  8931. g = Ext.Date.clearTime(g, true);
  8932. var c = [], h, e;
  8933. for (e = d; e < g; e = Sch.util.Date.getNext(e, Sch.util.Date.DAY, 1)) {
  8934. if (this.isHoliday(e)
  8935. || (this.weekendsAreWorkdays && a && this.isWeekend(e))) {
  8936. var i = this.getCalendarDay(e);
  8937. var j = i && i.getCls() || this.defaultNonWorkingTimeCssCls;
  8938. var f = Sch.util.Date.getNext(e, Sch.util.Date.DAY, 1);
  8939. if (!h) {
  8940. h = {
  8941. StartDate : e,
  8942. EndDate : f,
  8943. Cls : j
  8944. }
  8945. } else {
  8946. if (h.Cls == j) {
  8947. h.EndDate = f
  8948. } else {
  8949. c.push(h);
  8950. h = {
  8951. StartDate : e,
  8952. EndDate : f,
  8953. Cls : j
  8954. }
  8955. }
  8956. }
  8957. } else {
  8958. if (h) {
  8959. c.push(h);
  8960. h = null
  8961. }
  8962. }
  8963. }
  8964. if (h) {
  8965. c.push(h)
  8966. }
  8967. var b = [];
  8968. Ext.each(c, function(k) {
  8969. b.push(Ext.create("Sch.model.Range", {
  8970. StartDate : k.StartDate,
  8971. EndDate : k.EndDate,
  8972. Cls : k.Cls
  8973. }))
  8974. });
  8975. return b
  8976. },
  8977. forEachAvailabilityInterval : function(r, f, p) {
  8978. p = p || this;
  8979. var l = this;
  8980. var d = r.startDate;
  8981. var j = r.endDate;
  8982. var o = r.isForward !== false;
  8983. if (o ? !d : !j) {
  8984. throw new Error("At least `startDate` or `endDate` is required, depending from the `isForward` option")
  8985. }
  8986. var a = new Date(o ? d : j);
  8987. var q = o ? !j : !d;
  8988. var c = Sch.util.Date;
  8989. while (q || (o ? a < j : a > d)) {
  8990. var h = this.getAvailabilityIntervalsFor(a - (o ? 0 : 1));
  8991. for (var g = o ? 0 : h.length - 1; o ? g < h.length : g >= 0; o
  8992. ? g++
  8993. : g--) {
  8994. var b = h[g];
  8995. var k = b.startDate;
  8996. var n = b.endDate;
  8997. if (k >= j || n <= d) {
  8998. continue
  8999. }
  9000. var e = k < d ? d : k;
  9001. var m = n > j ? j : n;
  9002. if (f.call(p, e, m) === false) {
  9003. return false
  9004. }
  9005. }
  9006. a = o ? c.getStartOfNextDay(a) : c.getEndOfPreviousDay(a)
  9007. }
  9008. },
  9009. calculateDuration : function(a, d, b) {
  9010. var c = 0;
  9011. this.forEachAvailabilityInterval({
  9012. startDate : a,
  9013. endDate : d
  9014. }, function(g, f) {
  9015. var e = g.getTimezoneOffset() - f.getTimezoneOffset();
  9016. c += f - g + e * 60 * 1000
  9017. });
  9018. return this.convertMSDurationToUnit(c, b)
  9019. },
  9020. calculateEndDate : function(a, f, b) {
  9021. if (!f) {
  9022. return new Date(a)
  9023. }
  9024. var e = Sch.util.Date, d;
  9025. f = this.convertDurationToMs(f, b);
  9026. var c = f === 0 && Ext.Date.clearTime(a, true) - a === 0 ? e.add(a,
  9027. Sch.util.Date.DAY, -1) : a;
  9028. this.forEachAvailabilityInterval({
  9029. startDate : c
  9030. }, function(i, h) {
  9031. var j = h - i;
  9032. var g = i.getTimezoneOffset() - h.getTimezoneOffset();
  9033. if (j >= f) {
  9034. d = new Date(i - 0 + f);
  9035. return false
  9036. } else {
  9037. f -= j + g * 60 * 1000
  9038. }
  9039. });
  9040. return d
  9041. },
  9042. calculateStartDate : function(d, c, b) {
  9043. if (!c) {
  9044. return new Date(d)
  9045. }
  9046. var a;
  9047. c = this.convertDurationToMs(c, b);
  9048. this.forEachAvailabilityInterval({
  9049. endDate : d,
  9050. isForward : false
  9051. }, function(f, e) {
  9052. var g = e - f;
  9053. if (g >= c) {
  9054. a = new Date(e - c);
  9055. return false
  9056. } else {
  9057. c -= g
  9058. }
  9059. });
  9060. return a
  9061. },
  9062. skipNonWorkingTime : function(a, b) {
  9063. this.forEachAvailabilityInterval(b ? {
  9064. startDate : a
  9065. } : {
  9066. endDate : a,
  9067. isForward : false
  9068. }, function(d, c) {
  9069. a = b ? d : c;
  9070. return false
  9071. });
  9072. return new Date(a)
  9073. },
  9074. skipWorkingTime : function(a, c, b) {
  9075. return c >= 0 ? this.calculateEndDate(a, c, b) : this
  9076. .calculateStartDate(a, -c, b)
  9077. },
  9078. getAvailabilityIntervalsFor : function(a) {
  9079. a = Ext.Date.clearTime(new Date(a)) - 0;
  9080. if (this.availabilityIntervalsCache[a]) {
  9081. return this.availabilityIntervalsCache[a]
  9082. }
  9083. return this.availabilityIntervalsCache[a] = this.getCalendarDay(a)
  9084. .getAvailabilityIntervalsFor(a)
  9085. },
  9086. getParentableCalendars : function() {
  9087. var c = this, a = [], d = Gnt.data.Calendar.getAllCalendars();
  9088. var b = function(e) {
  9089. if (!e.parent) {
  9090. return false
  9091. }
  9092. if (e.parent == c) {
  9093. return true
  9094. }
  9095. return b(e.parent)
  9096. };
  9097. Ext.Array.each(d, function(e) {
  9098. if (e === c) {
  9099. return
  9100. }
  9101. if (!b(e)) {
  9102. a.push({
  9103. Id : e.calendarId,
  9104. Name : e.name || e.calendarId
  9105. })
  9106. }
  9107. });
  9108. return a
  9109. }
  9110. });
  9111. Ext.define("Gnt.data.calendar.BusinessTime", {
  9112. extend : "Gnt.data.Calendar",
  9113. daysPerMonth : 20,
  9114. daysPerWeek : 5,
  9115. hoursPerDay : 8,
  9116. defaultAvailability : ["08:00-12:00", "13:00-17:00"]
  9117. });
  9118. Ext.define("Gnt.data.TaskStore", {
  9119. extend : "Ext.data.TreeStore",
  9120. requires : ["Sch.patches.TreeStore", "Gnt.model.Task", "Gnt.data.Calendar"],
  9121. mixins : ["Sch.data.mixin.BufferableTreeStore",
  9122. "Sch.data.mixin.FilterableTreeStore", "Sch.data.mixin.EventStore"],
  9123. model : "Gnt.model.Task",
  9124. calendar : null,
  9125. dependencyStore : null,
  9126. resourceStore : null,
  9127. assignmentStore : null,
  9128. weekendsAreWorkdays : false,
  9129. buffered : false,
  9130. pageSize : null,
  9131. cascadeChanges : false,
  9132. batchSync : true,
  9133. recalculateParents : true,
  9134. skipWeekendsDuringDragDrop : true,
  9135. cascadeDelay : 0,
  9136. cascading : false,
  9137. isFillingRoot : false,
  9138. constructor : function(c) {
  9139. this.addEvents("root-fill-start", "root-fill-end", "filter",
  9140. "clearfilter", "beforecascade", "cascade");
  9141. c = c || {};
  9142. if (!c.calendar) {
  9143. var a = {};
  9144. if (c.hasOwnProperty("weekendsAreWorkdays")) {
  9145. a.weekendsAreWorkdays = c.weekendsAreWorkdays
  9146. } else {
  9147. if (this.self.prototype.hasOwnProperty("weekendsAreWorkdays")
  9148. && this.self != Gnt.data.TaskStore) {
  9149. a.weekendsAreWorkdays = this.weekendsAreWorkdays
  9150. }
  9151. }
  9152. c.calendar = new Gnt.data.Calendar(a)
  9153. }
  9154. this.hasListeners = {};
  9155. this.on({
  9156. "root-fill-end" : this.onRootFillEnd,
  9157. remove : this.onTaskDeleted,
  9158. beforesync : this.onTaskStoreBeforeSync,
  9159. write : this.onTaskStoreWrite,
  9160. scope : this
  9161. });
  9162. var b = c.dependencyStore;
  9163. if (b) {
  9164. delete c.dependencyStore;
  9165. this.setDependencyStore(b)
  9166. }
  9167. var d = c.resourceStore;
  9168. if (d) {
  9169. delete c.resourceStore;
  9170. this.setResourceStore(d)
  9171. }
  9172. var f = c.assignmentStore;
  9173. if (f) {
  9174. delete c.assignmentStore;
  9175. this.setAssignmentStore(f)
  9176. }
  9177. var e = c.calendar;
  9178. if (e) {
  9179. delete c.calendar;
  9180. this.setCalendar(e)
  9181. }
  9182. this.callParent([c]);
  9183. if (Ext.data.reader.Xml
  9184. && this.getProxy().getReader() instanceof Ext.data.reader.Xml) {
  9185. Ext.override(this.getProxy().getReader(), {
  9186. extractData : function(g) {
  9187. var h = this.record;
  9188. if (h != g.nodeName) {
  9189. g = Ext.DomQuery.select(">" + h, g)
  9190. } else {
  9191. g = [g]
  9192. }
  9193. return Ext.data.reader.Xml.superclass.extractData
  9194. .apply(this, [g])
  9195. }
  9196. })
  9197. }
  9198. if (this.autoSync && this.batchSync) {
  9199. this.sync = Ext.Function.createBuffered(this.sync, 500)
  9200. }
  9201. this.initTreeFiltering();
  9202. this.initTreeBuffering()
  9203. },
  9204. load : function() {
  9205. this.un("remove", this.onTaskDeleted, this);
  9206. this.callParent(arguments);
  9207. this.on("remove", this.onTaskDeleted, this)
  9208. },
  9209. loadData : function(B, w) {
  9210. var z = this, r = z.getRootNode(), c = w ? w.addRecords : false, t = w
  9211. ? w.syncStore
  9212. : false;
  9213. z.suspendAutoSync();
  9214. z.suspendEvents();
  9215. if (!c && r) {
  9216. r.removeAll()
  9217. }
  9218. if (!z.getRootNode()) {
  9219. r = z.setRootNode()
  9220. }
  9221. if (!B.length) {
  9222. return
  9223. } else {
  9224. var f = B.length, e = z.model, n = [], u = (typeof B[0].get === "function"), b, p, o, x, y, A, v, m, h;
  9225. for (var s = 0; s < f; s++) {
  9226. p = z.getById(B[s].getId ? B[s].getId() : B[s].Id);
  9227. b = 0;
  9228. if (p) {
  9229. x = u ? B[s].get("parentId") : B[s].parentId;
  9230. y = p.get("parentId");
  9231. A = u ? B[s].get("index") : B[s].index;
  9232. v = p.get("index");
  9233. if (u) {
  9234. p.set(B[s].data)
  9235. } else {
  9236. p.set(B[s])
  9237. }
  9238. if (((x || x === null) ? (x !== y) : false)
  9239. || (A ? (A !== v) : false)) {
  9240. m = x === null ? r : z.getById(x);
  9241. h = y === null ? r : z.getById(y)
  9242. } else {
  9243. b = 1
  9244. }
  9245. } else {
  9246. p = u ? new e(B[s].data) : new e(B[s]);
  9247. y = p.get("parentId");
  9248. if (y) {
  9249. m = z.getById(y)
  9250. } else {
  9251. if (y === null) {
  9252. m = r
  9253. }
  9254. }
  9255. }
  9256. if (m && !b) {
  9257. z.moveChildren(p, m, h)
  9258. } else {
  9259. if (typeof m === "undefined" && !b) {
  9260. o = {
  9261. node : p,
  9262. index : p.get("index") || 0,
  9263. parentId : p.get("parentId")
  9264. };
  9265. n.push(o)
  9266. }
  9267. }
  9268. if (m && !t) {
  9269. m.commit();
  9270. p.commit();
  9271. if (h) {
  9272. h.commit()
  9273. }
  9274. }
  9275. }
  9276. var g = 0, j = n.length, d, k;
  9277. if (n.length) {
  9278. z.sortNewNodesByIndex(n)
  9279. }
  9280. while (n.length) {
  9281. if (g > n.length - 1) {
  9282. g = 0
  9283. }
  9284. d = n[g];
  9285. k = d.parentId === null ? r : z.getById(d.parentId);
  9286. if (k) {
  9287. var a = z.nodeIsChild(d.node, m);
  9288. if (a) {
  9289. k.insertChild(d.index, d.node);
  9290. z.fixNodeDates(d.node);
  9291. n.splice(g, 1);
  9292. if (!t) {
  9293. k.commit();
  9294. d.node.commit()
  9295. }
  9296. g -= 1
  9297. }
  9298. }
  9299. g += 1;
  9300. if (g === j - 1 && n.length === j) {
  9301. throw "Invalid data, possible infinite loop."
  9302. }
  9303. }
  9304. if (z.nodesToExpand) {
  9305. s = 0;
  9306. for (var q = z.nodesToExpand.length; s < q; s += 1) {
  9307. p = z.nodesToExpand[s];
  9308. if (p.childNodes && p.childNodes.length) {
  9309. p.expand()
  9310. }
  9311. }
  9312. delete z.nodesToExpand
  9313. }
  9314. }
  9315. z.resumeAutoSync();
  9316. z.resumeEvents();
  9317. this.fireEvent("datachanged");
  9318. this.fireEvent("refresh");
  9319. if (t) {
  9320. z.sync()
  9321. }
  9322. },
  9323. sortNewNodesByIndex : function(a) {
  9324. Ext.Array.sort(a, function(b, e) {
  9325. var d = b.index, c = e.index;
  9326. if (d && c) {
  9327. if (d < c) {
  9328. return -1
  9329. } else {
  9330. if (d > c) {
  9331. return 1
  9332. } else {
  9333. return 0
  9334. }
  9335. }
  9336. }
  9337. return 0
  9338. })
  9339. },
  9340. fixNodeDates : function(b) {
  9341. var c = b.calculateDuration(b.getStartDate(), b.getEndDate(), b
  9342. .getDurationUnit()), a;
  9343. b.set({
  9344. Duration : c
  9345. });
  9346. if (this.recalculateParents) {
  9347. if (b.childNodes.length) {
  9348. a = b.getChildAt(0);
  9349. a.recalculateParents()
  9350. } else {
  9351. b.recalculateParents()
  9352. }
  9353. }
  9354. },
  9355. nodeIsChild : function(c, b) {
  9356. var d = b.getId(), a = true;
  9357. if (c.childNodes.length) {
  9358. c.cascadeBy(function(e) {
  9359. if (e.getId() === d) {
  9360. a = false;
  9361. return false
  9362. }
  9363. })
  9364. }
  9365. return a
  9366. },
  9367. moveChildren : function(e, d, c) {
  9368. if (e.get("expanded")) {
  9369. if (!this.nodesToExpand) {
  9370. this.nodesToExpand = []
  9371. }
  9372. this.nodesToExpand.push(e);
  9373. e.set("expanded", false)
  9374. }
  9375. var b, f = this.nodeIsChild(e, d), a = c
  9376. || this.getById(e.get("parentId"));
  9377. if (f) {
  9378. if (e.childNodes.length) {
  9379. b = e.copy(null, true);
  9380. e.removeAll()
  9381. }
  9382. if (a && a.getId() !== d.getId()) {
  9383. a.removeChild(e)
  9384. }
  9385. e.get("index") ? d.insertChild(e.get("index"), e) : d
  9386. .appendChild(e);
  9387. if (b) {
  9388. b.cascadeBy(function(h) {
  9389. if (h !== b) {
  9390. var g = h.copy(null);
  9391. g.get("index") ? e.insertChild(g.get("index"),
  9392. g) : e.appendChild(g)
  9393. }
  9394. })
  9395. }
  9396. this.fixNodeDates(e)
  9397. }
  9398. },
  9399. onNodeAdded : function(c, e) {
  9400. if (!e.normalized && !e.isRoot()) {
  9401. e.normalize()
  9402. }
  9403. if (Ext.isIE) {
  9404. var d = this, b = d.getProxy(), a = b.getReader(), f = e.raw
  9405. || e[e.persistenceProperty], g;
  9406. Ext.Array.remove(d.removed, e);
  9407. if (!e.isLeaf()) {
  9408. g = a.getRoot(f);
  9409. if (g) {
  9410. d.fillNode(e, a.extractData(g));
  9411. if (f[a.root]) {
  9412. delete f[a.root]
  9413. }
  9414. }
  9415. }
  9416. if (d.autoSync && !d.autoSyncSuspended && (e.phantom || e.dirty)) {
  9417. d.sync()
  9418. }
  9419. } else {
  9420. this.callParent(arguments)
  9421. }
  9422. },
  9423. setRootNode : function() {
  9424. var b = this;
  9425. this.tree.setRootNode = Ext.Function.createInterceptor(
  9426. this.tree.setRootNode, function(c) {
  9427. Ext.apply(c, {
  9428. calendar : b.calendar,
  9429. taskStore : b,
  9430. dependencyStore : b.dependencyStore,
  9431. phantom : false,
  9432. dirty : false
  9433. })
  9434. });
  9435. var a = this.callParent(arguments);
  9436. delete this.tree.setRootNode;
  9437. return a
  9438. },
  9439. fillNode : function(g, c) {
  9440. this.isFillingNode = true;
  9441. if (g.isRoot()) {
  9442. this.isFillingRoot = true;
  9443. this.un({
  9444. remove : this.onNodeUpdated,
  9445. append : this.onNodeUpdated,
  9446. insert : this.onNodeUpdated,
  9447. update : this.onTaskUpdated,
  9448. scope : this
  9449. });
  9450. this.fireEvent("root-fill-start", this, g, c)
  9451. }
  9452. var f = this, e = c ? c.length : 0, d = 0, b;
  9453. if (e && f.sortOnLoad && !f.remoteSort && f.sorters && f.sorters.items) {
  9454. b = Ext.create("Ext.util.MixedCollection");
  9455. b.addAll(c);
  9456. b.sort(f.sorters.items);
  9457. c = b.items
  9458. }
  9459. g.set("loaded", true);
  9460. if (this.buffered) {
  9461. for (; d < e; d++) {
  9462. var a = c[d];
  9463. a.__isFilling__ = true;
  9464. g.appendChild(a, true, true);
  9465. this.onNodeAdded(null, a);
  9466. this.tree.registerNode(a)
  9467. }
  9468. } else {
  9469. for (; d < e; d++) {
  9470. c[d].__isFilling__ = true;
  9471. g.appendChild(c[d], false, true)
  9472. }
  9473. }
  9474. if (g.isRoot()) {
  9475. this.getRootNode().cascadeBy(function(h) {
  9476. delete h.__isFilling__
  9477. });
  9478. this.isFillingRoot = false;
  9479. this.on({
  9480. remove : this.onNodeUpdated,
  9481. append : this.onNodeUpdated,
  9482. insert : this.onNodeUpdated,
  9483. update : this.onTaskUpdated,
  9484. scope : this
  9485. });
  9486. this.fireEvent("root-fill-end", this, g, c)
  9487. }
  9488. delete this.isFillingNode;
  9489. return c
  9490. },
  9491. onRootFillEnd : function(b, a) {
  9492. a.normalizeEffort()
  9493. },
  9494. getById : function(a) {
  9495. return this.tree.getNodeById(a)
  9496. },
  9497. setDependencyStore : function(a) {
  9498. if (this.dependencyStore) {
  9499. this.dependencyStore.un({
  9500. add : this.onDependencyAddOrUpdate,
  9501. update : this.onDependencyAddOrUpdate,
  9502. scope : this
  9503. })
  9504. }
  9505. this.dependencyStore = Ext.StoreMgr.lookup(a);
  9506. if (a) {
  9507. a.taskStore = this;
  9508. a.on({
  9509. add : this.onDependencyAddOrUpdate,
  9510. update : this.onDependencyAddOrUpdate,
  9511. scope : this
  9512. })
  9513. }
  9514. },
  9515. setResourceStore : function(a) {
  9516. this.resourceStore = Ext.StoreMgr.lookup(a);
  9517. a.taskStore = this
  9518. },
  9519. getResourceStore : function() {
  9520. return this.resourceStore || null
  9521. },
  9522. setAssignmentStore : function(a) {
  9523. if (this.assignmentStore) {
  9524. this.assignmentStore.un({
  9525. add : this.onAssignmentStructureMutation,
  9526. update : this.onAssignmentMutation,
  9527. remove : this.onAssignmentStructureMutation,
  9528. scope : this
  9529. })
  9530. }
  9531. this.assignmentStore = Ext.StoreMgr.lookup(a);
  9532. a.taskStore = this;
  9533. a.on({
  9534. add : this.onAssignmentStructureMutation,
  9535. update : this.onAssignmentMutation,
  9536. remove : this.onAssignmentStructureMutation,
  9537. scope : this
  9538. })
  9539. },
  9540. getAssignmentStore : function() {
  9541. return this.assignmentStore || null
  9542. },
  9543. renormalizeTasks : function(b, a) {
  9544. if (a instanceof Gnt.model.Task) {
  9545. a.adjustToCalendar()
  9546. } else {
  9547. this.getRootNode().cascadeBy(function(c) {
  9548. c.adjustToCalendar()
  9549. })
  9550. }
  9551. },
  9552. getCalendar : function() {
  9553. return this.calendar || null
  9554. },
  9555. setCalendar : function(c) {
  9556. var b = {
  9557. datachanged : this.renormalizeTasks,
  9558. update : this.renormalizeTasks,
  9559. clear : this.renormalizeTasks,
  9560. scope : this
  9561. };
  9562. if (this.calendar) {
  9563. this.calendar.un(b)
  9564. }
  9565. this.calendar = c;
  9566. c.on(b);
  9567. var a = this.tree && this.getRootNode();
  9568. if (a) {
  9569. a.calendar = c
  9570. }
  9571. },
  9572. filter : function() {
  9573. this.fireEvent("filter", this, arguments)
  9574. },
  9575. clearFilter : function() {
  9576. this.fireEvent("clearfilter", this)
  9577. },
  9578. getCriticalPaths : function() {
  9579. var b = this.getRootNode(), a = [], d = new Date(0);
  9580. b.cascadeBy(function(e) {
  9581. d = Sch.util.Date.max(e.getEndDate(), d)
  9582. });
  9583. b.cascadeBy(function(e) {
  9584. if (d - e.getEndDate() === 0 && !e.isRoot()) {
  9585. a.push(e)
  9586. }
  9587. });
  9588. var c = [];
  9589. Ext.each(a, function(e) {
  9590. c.push(e.getCriticalPaths())
  9591. });
  9592. return c
  9593. },
  9594. onNodeUpdated : function(a, b) {
  9595. if (!this.cascading && this.recalculateParents && !this.isFillingNode) {
  9596. b.recalculateParents()
  9597. }
  9598. },
  9599. onTaskUpdated : function(c, b, a) {
  9600. var d = b.previous;
  9601. if (!this.cascading
  9602. && !this.isFillingNode
  9603. && a !== Ext.data.Model.COMMIT
  9604. && (d && (b.startDateField in d || b.endDateField in d
  9605. || "parentId" in d || b.effortField in d))) {
  9606. if (this.cascadeChanges) {
  9607. Ext.Function.defer(this.cascadeChangesForTask,
  9608. this.cascadeDelay, this, [b])
  9609. }
  9610. if (this.recalculateParents) {
  9611. b.recalculateParents()
  9612. }
  9613. }
  9614. },
  9615. cascadeChangesForTask : function(a) {
  9616. var c = this, b = {
  9617. nbrAffected : 0
  9618. };
  9619. Ext.each(a.getOutgoingDependencies(), function(d) {
  9620. var e = d.getTargetTask();
  9621. if (e) {
  9622. if (!c.cascading) {
  9623. c.fireEvent("beforecascade", c)
  9624. }
  9625. c.cascading = true;
  9626. e.cascadeChanges(c, b, d)
  9627. }
  9628. });
  9629. if (c.cascading) {
  9630. c.cascading = false;
  9631. c.fireEvent("cascade", c, b)
  9632. }
  9633. },
  9634. onTaskDeleted : function(c, b) {
  9635. var a = this.dependencyStore;
  9636. if (a && !b.isReplace && !b.isMove) {
  9637. a.remove(b.getAllDependencies(a))
  9638. }
  9639. },
  9640. onAssignmentMutation : function(c, a) {
  9641. var b = this;
  9642. Ext.each(a, function(e) {
  9643. var d = e.getTask(b);
  9644. if (d) {
  9645. d.onAssignmentMutation(e)
  9646. }
  9647. })
  9648. },
  9649. onAssignmentStructureMutation : function(c, a) {
  9650. var b = this;
  9651. Ext.each(a, function(d) {
  9652. d.getTask(b).onAssignmentStructureMutation(d)
  9653. })
  9654. },
  9655. onDependencyAddOrUpdate : function(b, d) {
  9656. if (this.cascadeChanges) {
  9657. var c = this, a;
  9658. Ext.each(d, function(e) {
  9659. a = e.getTargetTask();
  9660. if (a) {
  9661. a.constrain(c)
  9662. }
  9663. })
  9664. }
  9665. },
  9666. getNewRecords : function() {
  9667. return Ext.Array.filter(this.tree.flatten(), this.filterNew, this)
  9668. },
  9669. getUpdatedRecords : function() {
  9670. return Ext.Array.filter(this.tree.flatten(), this.filterUpdated, this)
  9671. },
  9672. filterNew : function(a) {
  9673. return a.phantom && a.isValid() && a != this.tree.root
  9674. },
  9675. filterUpdated : function(a) {
  9676. return a.dirty && !a.phantom && a.isValid() && a != this.tree.root
  9677. },
  9678. onTaskStoreBeforeSync : function(b, c) {
  9679. var a = b.create;
  9680. if (a) {
  9681. for (var e, d = a.length - 1; d >= 0; d--) {
  9682. e = a[d];
  9683. if (e.isPersistable()) {
  9684. e._phantomId = e.internalId
  9685. } else {
  9686. if (this.autoSync) {
  9687. Ext.Array.remove(a, e)
  9688. }
  9689. }
  9690. }
  9691. if (a.length === 0) {
  9692. delete b.create
  9693. }
  9694. }
  9695. return Boolean((b.create && b.create.length > 0)
  9696. || (b.update && b.update.length > 0)
  9697. || (b.destroy && b.destroy.length > 0))
  9698. },
  9699. onTaskStoreWrite : function(c, b) {
  9700. var d = this.dependencyStore;
  9701. if (!d || b.action !== "create") {
  9702. return
  9703. }
  9704. var a = b.getRecords(), e;
  9705. Ext.each(a, function(f) {
  9706. e = f.getId();
  9707. if (!f.phantom && e !== f._phantomId) {
  9708. Ext.each(d.getNewRecords(), function(g) {
  9709. var i = g.getSourceId();
  9710. var h = g.getTargetId();
  9711. if (i === f._phantomId) {
  9712. g.setSourceId(e)
  9713. } else {
  9714. if (h === f._phantomId) {
  9715. g.setTargetId(e)
  9716. }
  9717. }
  9718. });
  9719. Ext.each(f.childNodes, function(g) {
  9720. if (g.phantom) {
  9721. g.set("parentId", e)
  9722. }
  9723. });
  9724. delete f._phantomId
  9725. }
  9726. })
  9727. },
  9728. getTotalTimeSpan : function() {
  9729. var a = new Date(9999, 0, 1), b = new Date(0), c = Sch.util.Date;
  9730. this.getRootNode().cascadeBy(function(d) {
  9731. if (d.getStartDate()) {
  9732. a = c.min(d.getStartDate(), a)
  9733. }
  9734. if (d.getEndDate()) {
  9735. b = c.max(d.getEndDate(), b)
  9736. }
  9737. });
  9738. a = a < new Date(9999, 0, 1) ? a : null;
  9739. b = b > new Date(0) ? b : null;
  9740. return {
  9741. start : a,
  9742. end : b || a || null
  9743. }
  9744. },
  9745. getCount : function(b) {
  9746. var a = b === false ? 0 : -1;
  9747. this.getRootNode().cascadeBy(function() {
  9748. a++
  9749. });
  9750. return a
  9751. },
  9752. toArray : function() {
  9753. var a = [];
  9754. this.getRootNode().cascadeBy(function(b) {
  9755. a.push(b)
  9756. });
  9757. return a
  9758. },
  9759. remove : function(a) {
  9760. Ext.each(a, function(b) {
  9761. b.remove()
  9762. })
  9763. },
  9764. indent : function(b) {
  9765. b = Ext.isArray(b) ? b : [b];
  9766. var a = Ext.Array.sort(b, function(d, c) {
  9767. return d.data.index > c.data.index
  9768. });
  9769. Ext.each(a, function(c) {
  9770. c.indent()
  9771. })
  9772. },
  9773. outdent : function(b) {
  9774. var a = Ext.Array.sort(b, function(d, c) {
  9775. return d.data.index > c.data.index
  9776. });
  9777. Ext.each(a, function(c) {
  9778. c.indent()
  9779. });
  9780. Ext.each(b, function(c) {
  9781. c.outdent()
  9782. })
  9783. },
  9784. getTasksForResource : function(a) {
  9785. return a.getTasks()
  9786. },
  9787. getEventsForResource : function(a) {
  9788. return this.getTasksForResource(a)
  9789. },
  9790. ensureSingleSyncForMethod : function() {
  9791. return function() {
  9792. var b;
  9793. if (this.autoSync && !this.autoSyncSuspended) {
  9794. b = true;
  9795. this.suspendAutoSync()
  9796. }
  9797. var a = this.callParent(arguments);
  9798. if (b) {
  9799. this.resumeAutoSync();
  9800. this.sync()
  9801. }
  9802. return a
  9803. }
  9804. },
  9805. indexOf : function(a) {
  9806. return a && this.tree.getNodeById(a.internalId) ? 0 : -1
  9807. },
  9808. getByInternalId : function(a) {
  9809. return this.tree.getNodeById(a)
  9810. }
  9811. }, function() {
  9812. var a = ["indent", "outdent", "afterEdit", "remove"];
  9813. Ext.each(a, function(c) {
  9814. var b = {};
  9815. b[c] = this.prototype
  9816. .ensureSingleSyncForMethod(this.prototype[c]);
  9817. this.override(b)
  9818. }, this)
  9819. });
  9820. Ext.define("Gnt.data.DependencyStore", {
  9821. extend : "Ext.data.Store",
  9822. model : "Gnt.model.Dependency",
  9823. constructor : function() {
  9824. this.callParent(arguments);
  9825. this.init()
  9826. },
  9827. init : function() {
  9828. this.on({
  9829. beforesync : this.onBeforeSyncOperation,
  9830. scope : this
  9831. })
  9832. },
  9833. onBeforeSyncOperation : function(a, b) {
  9834. if (a.create) {
  9835. for (var d, c = a.create.length - 1; c >= 0; c--) {
  9836. d = a.create[c];
  9837. if (!d.isPersistable()) {
  9838. Ext.Array.remove(a.create, d)
  9839. }
  9840. }
  9841. if (a.create.length === 0) {
  9842. delete a.create
  9843. }
  9844. }
  9845. return Boolean((a.create && a.create.length > 0)
  9846. || (a.update && a.update.length > 0)
  9847. || (a.destroy && a.destroy.length > 0))
  9848. },
  9849. getDependenciesForTask : function(b) {
  9850. var g = b.getId() || b.internalId;
  9851. var e = [], f = this;
  9852. for (var d = 0, a = f.getCount(); d < a; d++) {
  9853. var c = f.getAt(d);
  9854. if (c.getSourceId() == g || c.getTargetId() == g) {
  9855. e.push(c)
  9856. }
  9857. }
  9858. return e
  9859. },
  9860. getIncomingDependenciesForTask : function(b) {
  9861. var g = b.getId() || b.internalId;
  9862. var e = [], f = this;
  9863. for (var d = 0, a = f.getCount(); d < a; d++) {
  9864. var c = f.getAt(d);
  9865. if (c.getTargetId() == g) {
  9866. e.push(c)
  9867. }
  9868. }
  9869. return e
  9870. },
  9871. getOutgoingDependenciesForTask : function(b) {
  9872. var g = b.getId() || b.internalId;
  9873. var e = [], f = this;
  9874. for (var d = 0, a = f.getCount(); d < a; d++) {
  9875. var c = f.getAt(d);
  9876. if (c.getSourceId() == g) {
  9877. e.push(c)
  9878. }
  9879. }
  9880. return e
  9881. },
  9882. hasTransitiveDependency : function(d, b, a) {
  9883. var c = this;
  9884. return this.findBy(function(f) {
  9885. var e = f.getTargetId();
  9886. if (f.getSourceId() === d) {
  9887. return (e === b && f !== a) ? true : c
  9888. .hasTransitiveDependency(f
  9889. .getTargetId(), b, a)
  9890. }
  9891. }) >= 0
  9892. },
  9893. isValidDependency : function(h, b, e) {
  9894. var f = true;
  9895. var d, c, a;
  9896. if (h instanceof Gnt.model.Dependency) {
  9897. d = h.getSourceId();
  9898. c = this.getSourceTask(d);
  9899. b = h.getTargetId();
  9900. a = this.getTargetTask(b)
  9901. } else {
  9902. d = h;
  9903. c = this.getSourceTask(d);
  9904. a = this.getTargetTask(b)
  9905. }
  9906. if (!e && h instanceof Gnt.model.Dependency) {
  9907. f = h.isValid()
  9908. } else {
  9909. f = d && b && d !== b
  9910. }
  9911. if (f) {
  9912. if (c && a && (c.contains(a) || a.contains(c))) {
  9913. f = false
  9914. }
  9915. var g = e || (h instanceof Gnt.model.Dependency);
  9916. if (f
  9917. && ((!g && this.areTasksLinked(d, b)) || this
  9918. .hasTransitiveDependency(b, d, g ? h : null))) {
  9919. f = false
  9920. }
  9921. }
  9922. return f
  9923. },
  9924. areTasksLinked : function(c, e) {
  9925. var d = this;
  9926. var b = c instanceof Gnt.model.Task
  9927. ? (c.getId() || c.internalId)
  9928. : c;
  9929. var a = e instanceof Gnt.model.Task
  9930. ? (e.getId() || e.internalId)
  9931. : e;
  9932. return !!this.getByTaskIds(b, a)
  9933. },
  9934. getByTaskIds : function(c, b) {
  9935. var d = this;
  9936. var a = this.findBy(function(g) {
  9937. var e = g.getTargetId(), f = g.getSourceId();
  9938. if ((f === c && e === b) || (f === b && e === c)) {
  9939. return true
  9940. }
  9941. });
  9942. return this.getAt(a)
  9943. },
  9944. getSourceTask : function(a) {
  9945. var b = a instanceof Gnt.model.Dependency ? a.getSourceId() : a;
  9946. return this.getTaskStore().getById(b)
  9947. },
  9948. getTargetTask : function(a) {
  9949. var b = a instanceof Gnt.model.Dependency ? a.getTargetId() : a;
  9950. return this.getTaskStore().getById(b)
  9951. },
  9952. getTaskStore : function() {
  9953. return this.taskStore
  9954. }
  9955. });
  9956. Ext.define("Gnt.data.ResourceStore", {
  9957. requires : ["Gnt.model.Resource"],
  9958. extend : "Sch.data.ResourceStore",
  9959. model : "Gnt.model.Resource",
  9960. taskStore : null,
  9961. getTaskStore : function() {
  9962. return this.taskStore || null
  9963. },
  9964. getAssignmentStore : function() {
  9965. return this.assignmentStore || null
  9966. },
  9967. getByInternalId : function(a) {
  9968. return this.data.getByKey(a) || this.getById(a)
  9969. }
  9970. });
  9971. Ext.define("Gnt.data.AssignmentStore", {
  9972. requires : ["Gnt.model.Assignment"],
  9973. extend : "Ext.data.Store",
  9974. model : "Gnt.model.Assignment",
  9975. taskStore : null,
  9976. getTaskStore : function() {
  9977. return this.taskStore
  9978. },
  9979. getResourceStore : function() {
  9980. return this.getTaskStore().resourceStore
  9981. },
  9982. getByInternalId : function(a) {
  9983. return this.data.getByKey(a) || this.getById(a)
  9984. }
  9985. });
  9986. Ext.define("Gnt.template.Task", {
  9987. extend : "Ext.XTemplate",
  9988. constructor : function(a) {
  9989. this
  9990. .callParent([
  9991. '<div class="sch-event-wrap '
  9992. + a.baseCls
  9993. + ' x-unselectable" style="left:{leftOffset}px;">'
  9994. + (a.leftLabel
  9995. ? '<div class="sch-gantt-labelct sch-gantt-labelct-left"><label class="sch-gantt-label sch-gantt-label-left">{leftLabel}</label></div>'
  9996. : "")
  9997. + '<div id="'
  9998. + a.prefix
  9999. + '{id}" class="sch-gantt-item sch-gantt-task-bar {cls}" unselectable="on" style="width:{width}px;{style}">'
  10000. + (a.enableDependencyDragDrop
  10001. ? '<div unselectable="on" class="sch-gantt-terminal sch-gantt-terminal-start"></div>'
  10002. : "")
  10003. + ((a.resizeHandles === "both" || a.resizeHandles === "left")
  10004. ? '<div class="sch-resizable-handle sch-gantt-task-handle sch-resizable-handle-west"></div>'
  10005. : "")
  10006. + '<div class="sch-gantt-progress-bar" style="width:{percentDone}%;{progressBarStyle}" unselectable="on">&#160;</div>'
  10007. + ((a.resizeHandles === "both" || a.resizeHandles === "right")
  10008. ? '<div class="sch-resizable-handle sch-gantt-task-handle sch-resizable-handle-east"></div>'
  10009. : "")
  10010. + (a.enableDependencyDragDrop
  10011. ? '<div unselectable="on" class="sch-gantt-terminal sch-gantt-terminal-end"></div>'
  10012. : "")
  10013. + (a.enableProgressBarResize
  10014. ? '<div style="left:{percentDone}%" class="sch-gantt-progressbar-handle"></div>'
  10015. : "")
  10016. + "</div>"
  10017. + (a.rightLabel
  10018. ? '<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>'
  10019. : "") + "</div>", {
  10020. compiled : true,
  10021. disableFormats : true
  10022. }])
  10023. }
  10024. });
  10025. Ext.define("Gnt.template.Milestone", {
  10026. extend : "Ext.XTemplate",
  10027. constructor : function(a) {
  10028. this
  10029. .callParent([
  10030. '<div class="sch-event-wrap '
  10031. + a.baseCls
  10032. + ' x-unselectable" style="left:{leftOffset}px">'
  10033. + (a.leftLabel
  10034. ? '<div class="sch-gantt-labelct sch-gantt-labelct-left"><label class="sch-gantt-label sch-gantt-label-left">{leftLabel}</label></div>'
  10035. : "")
  10036. + (a.printable
  10037. ? ('<img id="' + a.prefix
  10038. + '{id}" src="' + a.imgSrc + '" class="sch-gantt-item sch-gantt-milestone-diamond {cls}" unselectable="on" style="{style}" />')
  10039. : ('<div id="'
  10040. + a.prefix
  10041. + '{id}" class="sch-gantt-item sch-gantt-milestone-diamond {cls}" unselectable="on" style="{style}">'
  10042. + (a.enableDependencyDragDrop
  10043. ? '<div class="sch-gantt-terminal sch-gantt-terminal-start"></div><div class="sch-gantt-terminal sch-gantt-terminal-end"></div>'
  10044. : "") + "</div>"))
  10045. + (a.rightLabel
  10046. ? '<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>'
  10047. : "") + "</div>", {
  10048. compiled : true,
  10049. disableFormats : true
  10050. }])
  10051. }
  10052. });
  10053. Ext.define("Gnt.template.ParentTask", {
  10054. extend : "Ext.XTemplate",
  10055. constructor : function(a) {
  10056. this
  10057. .callParent([
  10058. '<div class="sch-event-wrap '
  10059. + a.baseCls
  10060. + ' x-unselectable" style="left:{leftOffset}px;">'
  10061. + (a.leftLabel
  10062. ? '<div class="sch-gantt-labelct sch-gantt-labelct-left"><label class="sch-gantt-label sch-gantt-label-left">{leftLabel}</label></div>'
  10063. : "")
  10064. + '<div id="'
  10065. + a.prefix
  10066. + '{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>'
  10067. + (a.enableDependencyDragDrop
  10068. ? '<div class="sch-gantt-terminal sch-gantt-terminal-start"></div>'
  10069. : "")
  10070. + '<div class="sch-gantt-parenttask-arrow sch-gantt-parenttask-leftarrow"></div><div class="sch-gantt-parenttask-arrow sch-gantt-parenttask-rightarrow"></div>'
  10071. + (a.enableDependencyDragDrop
  10072. ? '<div class="sch-gantt-terminal sch-gantt-terminal-end"></div>'
  10073. : "")
  10074. + "</div>"
  10075. + (a.rightLabel
  10076. ? '<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>'
  10077. : "") + "</div>", {
  10078. compiled : true,
  10079. disableFormats : true
  10080. }])
  10081. }
  10082. });
  10083. Ext.define("Gnt.Tooltip", {
  10084. extend : "Ext.ToolTip",
  10085. requires : ["Ext.Template"],
  10086. startText : "Starts: ",
  10087. endText : "Ends: ",
  10088. durationText : "Duration:",
  10089. mode : "startend",
  10090. cls : "sch-tip",
  10091. height : 40,
  10092. autoHide : false,
  10093. anchor : "b-tl",
  10094. maskOnDisable : false,
  10095. initComponent : function() {
  10096. if (this.mode === "startend" && !this.startEndTemplate) {
  10097. this.startEndTemplate = new Ext.Template('<div class="sch-timetipwrap {cls}"><div>'
  10098. + this.startText
  10099. + "{startText}</div><div>"
  10100. + this.endText
  10101. + "{endText}</div></div>").compile()
  10102. }
  10103. if (this.mode === "duration" && !this.durationTemplate) {
  10104. this.durationTemplate = new Ext.Template(
  10105. '<div class="sch-timetipwrap {cls}">', "<div>"
  10106. + this.startText + " {startText}</div>", "<div>"
  10107. + this.durationText + " {duration} {unit}</div>",
  10108. "</div>").compile()
  10109. }
  10110. this.callParent(arguments)
  10111. },
  10112. update : function(e, b, d, a) {
  10113. var c;
  10114. if (this.mode === "duration") {
  10115. c = this.getDurationContent(e, b, d, a)
  10116. } else {
  10117. c = this.getStartEndContent(e, b, d, a)
  10118. }
  10119. this.callParent([c])
  10120. },
  10121. getStartEndContent : function(b, f, a, h) {
  10122. var e = this.gantt, i = e.getFormattedDate(b), d = i, g;
  10123. if (f - b > 0) {
  10124. d = e.getFormattedEndDate(f, b)
  10125. }
  10126. var c = {
  10127. cls : a ? "sch-tip-ok" : "sch-tip-notok",
  10128. startText : i,
  10129. endText : d
  10130. };
  10131. if (this.showClock) {
  10132. Ext.apply(c, {
  10133. startHourDegrees : roundedStart.getHours() * 30,
  10134. startMinuteDegrees : roundedStart.getMinutes() * 6
  10135. });
  10136. if (f) {
  10137. Ext.apply(c, {
  10138. endHourDegrees : g.getHours() * 30,
  10139. endMinuteDegrees : g.getMinutes() * 6
  10140. })
  10141. }
  10142. }
  10143. return this.startEndTemplate.apply(c)
  10144. },
  10145. getDurationContent : function(f, b, d, a) {
  10146. var c = a.getDurationUnit() || Sch.util.Date.DAY;
  10147. var e = a.calculateDuration(f, b, c);
  10148. return this.durationTemplate.apply({
  10149. cls : d ? "sch-tip-ok" : "sch-tip-notok",
  10150. startText : this.gantt.getFormattedDate(f),
  10151. duration : parseFloat(Ext.Number.toFixed(e, 1)),
  10152. unit : Sch.util.Date.getReadableNameOfUnit(c, e > 1)
  10153. })
  10154. },
  10155. show : function(a) {
  10156. if (a) {
  10157. this.setTarget(a)
  10158. }
  10159. this.callParent([])
  10160. }
  10161. });
  10162. Ext.define("Gnt.feature.TaskDragDrop", {
  10163. extend : "Ext.dd.DragZone",
  10164. requires : ["Gnt.Tooltip", "Ext.dd.StatusProxy", "Ext.dd.ScrollManager"],
  10165. onDragEnter : Ext.emptyFn,
  10166. onDragOut : Ext.emptyFn,
  10167. constructor : function(a) {
  10168. a = a || {};
  10169. Ext.apply(this, a);
  10170. this.proxy = this.proxy || Ext.create("Ext.dd.StatusProxy", {
  10171. shadow : false,
  10172. dropAllowed : "sch-gantt-dragproxy",
  10173. dropNotAllowed : "sch-gantt-dragproxy",
  10174. ensureAttachedToBody : Ext.emptyFn
  10175. });
  10176. var c = this, b = c.gantt;
  10177. if (c.useTooltip) {
  10178. c.tip = Ext.create("Gnt.Tooltip", {
  10179. gantt : b
  10180. })
  10181. }
  10182. c.callParent([b.el, Ext.apply(a, {
  10183. ddGroup : c.gantt.id + "-task-dd"
  10184. })]);
  10185. c.scroll = false;
  10186. c.isTarget = true;
  10187. c.ignoreSelf = false;
  10188. c.addInvalidHandleClass("sch-resizable-handle");
  10189. c.addInvalidHandleClass("x-resizable-handle");
  10190. c.addInvalidHandleClass("sch-gantt-terminal");
  10191. c.addInvalidHandleClass("sch-gantt-progressbar-handle");
  10192. Ext.dd.ScrollManager.register(c.gantt.el);
  10193. c.gantt.ownerCt.el.appendChild(this.proxy.el);
  10194. c.gantt.on({
  10195. destroy : c.cleanUp,
  10196. scope : c
  10197. })
  10198. },
  10199. useTooltip : true,
  10200. validatorFn : function(a, b, d, c) {
  10201. return true
  10202. },
  10203. validatorFnScope : null,
  10204. cleanUp : function() {
  10205. if (this.tip) {
  10206. this.tip.destroy()
  10207. }
  10208. this.destroy()
  10209. },
  10210. containerScroll : false,
  10211. dropAllowed : "sch-gantt-dragproxy",
  10212. dropNotAllowed : "sch-gantt-dragproxy",
  10213. destroy : function() {
  10214. this.callParent(arguments);
  10215. Ext.dd.ScrollManager.unregister(this.gantt.el)
  10216. },
  10217. autoOffset : function(a, e) {
  10218. var d = this.dragData.repairXY, c = a - d[0], b = e - d[1];
  10219. this.setDelta(c, b)
  10220. },
  10221. setXConstraint : function(c, b, a) {
  10222. this.leftConstraint = c;
  10223. this.rightConstraint = b;
  10224. this.minX = c;
  10225. this.maxX = b;
  10226. if (a) {
  10227. this.setXTicks(this.initPageX, a)
  10228. }
  10229. this.constrainX = true
  10230. },
  10231. setYConstraint : function(a, c, b) {
  10232. this.topConstraint = a;
  10233. this.bottomConstraint = c;
  10234. this.minY = a;
  10235. this.maxY = c;
  10236. if (b) {
  10237. this.setYTicks(this.initPageY, b)
  10238. }
  10239. this.constrainY = true
  10240. },
  10241. constrainTo : function(a, b) {
  10242. this.resetConstraints();
  10243. this.initPageX = a.left;
  10244. this.initPageY = b.top;
  10245. this.setXConstraint(a.left, a.right - (b.right - b.left),
  10246. this.xTickSize);
  10247. this.setYConstraint(b.top - 1, b.top - 1, this.yTickSize)
  10248. },
  10249. onDragOver : function(h, i) {
  10250. var g = this.dragData, f = g.record, d = this.gantt, b = this.proxy.el
  10251. .getX()
  10252. + d.getXOffset(f), a = d.getDateFromXY([b, 0], "round");
  10253. if (!g.hidden) {
  10254. Ext.fly(g.sourceNode).hide();
  10255. g.hidden = true
  10256. }
  10257. if (!a || a - g.start === 0) {
  10258. return
  10259. }
  10260. g.start = a;
  10261. this.valid = this.validatorFn.call(this.validatorFnScope || d, f, a,
  10262. g.duration, h) !== false;
  10263. if (this.tip) {
  10264. var c = f.calculateEndDate(a, f.getDuration(), f.getDurationUnit());
  10265. this.updateTip(f, a, c)
  10266. }
  10267. },
  10268. onStartDrag : function() {
  10269. var a = this.dragData.record;
  10270. if (this.tip) {
  10271. this.tip.enable();
  10272. this.tip.show(Ext.get(this.dragData.sourceNode));
  10273. this.updateTip(a, a.getStartDate(), a.getEndDate())
  10274. }
  10275. this.gantt.fireEvent("taskdragstart", this.gantt, a)
  10276. },
  10277. updateTip : function(b, c, a) {
  10278. if (b.isMilestone() && c - Ext.Date.clearTime(c, true) === 0) {
  10279. c = Sch.util.Date.add(c, Sch.util.Date.MILLI, -1);
  10280. a = Sch.util.Date.add(a, Sch.util.Date.MILLI, -1)
  10281. }
  10282. this.tip.update(c, a, true)
  10283. },
  10284. getDragData : function(i) {
  10285. var h = this.gantt, f = i.getTarget(h.eventSelector);
  10286. if (f && !i.getTarget(".sch-gantt-baseline-item")) {
  10287. var c = Ext.get(f), d = h.resolveTaskRecord(c);
  10288. if (h.fireEvent("beforetaskdrag", h, d, i) === false) {
  10289. return null
  10290. }
  10291. var j = f.cloneNode(true), b = h.getSnapPixelAmount(), a = c
  10292. .getXY();
  10293. j.id = Ext.id();
  10294. if (b <= 1) {
  10295. Ext.fly(j).setStyle("left", 0)
  10296. }
  10297. this.constrainTo(Ext.fly(h.findItemByChild(f)).getRegion(), c
  10298. .getRegion());
  10299. if (b >= 1) {
  10300. this.setXConstraint(this.leftConstraint, this.rightConstraint,
  10301. b)
  10302. }
  10303. return {
  10304. sourceNode : f,
  10305. repairXY : a,
  10306. ddel : j,
  10307. record : d,
  10308. duration : Sch.util.Date.getDurationInMinutes(d.getStartDate(),
  10309. d.getEndDate())
  10310. }
  10311. }
  10312. return null
  10313. },
  10314. afterRepair : function() {
  10315. Ext.fly(this.dragData.sourceNode).show();
  10316. if (this.tip) {
  10317. this.tip.hide()
  10318. }
  10319. this.dragging = false
  10320. },
  10321. getRepairXY : function() {
  10322. this.gantt.fireEvent("afterdnd", this.gantt);
  10323. return this.dragData.repairXY
  10324. },
  10325. onDragDrop : function(g, i) {
  10326. var f = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(i), d = this.dragData, b = this.gantt, a = d.record, h = d.start;
  10327. var c = false;
  10328. if (this.tip) {
  10329. this.tip.disable()
  10330. }
  10331. if (this.valid && h && a.getStartDate() - h !== 0) {
  10332. b.taskStore.on("update", function() {
  10333. c = true
  10334. }, null, {
  10335. single : true
  10336. });
  10337. a.setStartDate(h, true, b.taskStore.skipWeekendsDuringDragDrop);
  10338. if (c) {
  10339. b.fireEvent("taskdrop", b, a);
  10340. if (Ext.isIE9) {
  10341. this.proxy.el.setStyle("visibility", "hidden");
  10342. Ext.Function.defer(this.onValidDrop, 10, this, [f, g, i])
  10343. } else {
  10344. this.onValidDrop(f, g, i)
  10345. }
  10346. }
  10347. }
  10348. if (!c) {
  10349. this.onInvalidDrop(f, g, i)
  10350. }
  10351. b.fireEvent("aftertaskdrop", b, a)
  10352. }
  10353. });
  10354. Ext.define("Gnt.feature.DependencyDragDrop", {
  10355. extend : "Ext.util.Observable",
  10356. constructor : function(b) {
  10357. this.addEvents("beforednd", "dndstart", "drop", "afterdnd");
  10358. var a = b.ganttView;
  10359. Ext.apply(this, {
  10360. el : a.el,
  10361. ddGroup : a.id + "-sch-dependency-dd",
  10362. ganttView : a,
  10363. dependencyStore : a.getDependencyStore()
  10364. });
  10365. this.el.on("mousemove", function() {
  10366. this.setupDragZone();
  10367. this.setupDropZone()
  10368. }, this, {
  10369. single : true
  10370. });
  10371. this.callParent(arguments)
  10372. },
  10373. fromText : "From: <strong>{0}</strong> {1}<br/>",
  10374. toText : "To: <strong>{0}</strong> {1}",
  10375. startText : "Start",
  10376. endText : "End",
  10377. useLineProxy : true,
  10378. terminalSelector : ".sch-gantt-terminal",
  10379. destroy : function() {
  10380. if (this.dragZone) {
  10381. this.dragZone.destroy()
  10382. }
  10383. if (this.dropZone) {
  10384. this.dropZone.destroy()
  10385. }
  10386. if (this.lineProxyEl) {
  10387. this.lineProxyEl.destroy()
  10388. }
  10389. },
  10390. initLineProxy : function(b, a) {
  10391. var c = this.lineProxyEl = this.el.createChild({
  10392. cls : "sch-gantt-connector-proxy"
  10393. });
  10394. c.alignTo(b, a ? "l" : "r");
  10395. Ext.apply(this, {
  10396. containerTop : this.el.getTop(),
  10397. containerLeft : this.el.getLeft(),
  10398. startXY : c.getXY(),
  10399. startScrollLeft : this.el.dom.scrollLeft,
  10400. startScrollTop : this.el.dom.scrollTop
  10401. })
  10402. },
  10403. updateLineProxy : function(m) {
  10404. var a = this.lineProxyEl, j = m[0] - this.startXY[0]
  10405. + this.el.dom.scrollLeft - this.startScrollLeft, i = m[1]
  10406. - this.startXY[1] + this.el.dom.scrollTop - this.startScrollTop, b = Math
  10407. .max(1, Math.sqrt(Math.pow(j, 2) + Math.pow(i, 2)) - 2), h = Math
  10408. .atan2(i, j)
  10409. - (Math.PI / 2), e;
  10410. if (Ext.isIE) {
  10411. var k = Math.cos(h), g = Math.sin(h), l = 'progid:DXImageTransform.Microsoft.Matrix(sizingMethod="auto expand", M11 = '
  10412. + k
  10413. + ", M12 = "
  10414. + (-g)
  10415. + ", M21 = "
  10416. + g
  10417. + ", M22 = "
  10418. + k
  10419. + ")", d, f;
  10420. if (this.el.dom.scrollTop !== this.startScrollTop) {
  10421. d = this.startScrollTop - this.containerTop
  10422. } else {
  10423. d = this.el.dom.scrollTop - this.containerTop
  10424. }
  10425. if (this.el.dom.scrollLeft !== this.startScrollLeft) {
  10426. f = this.startScrollLeft - this.containerLeft
  10427. } else {
  10428. f = this.el.dom.scrollLeft - this.containerLeft
  10429. }
  10430. e = {
  10431. height : b + "px",
  10432. top : Math.min(0, i) + this.startXY[1] + d + (i < 0 ? 2 : 0)
  10433. + "px",
  10434. left : Math.min(0, j) + this.startXY[0] + f + (j < 0 ? 2 : 0)
  10435. + "px",
  10436. filter : l,
  10437. "-ms-filter" : l
  10438. }
  10439. } else {
  10440. var c = "rotate(" + h + "rad)";
  10441. e = {
  10442. height : b + "px",
  10443. "-o-transform" : c,
  10444. "-webkit-transform" : c,
  10445. "-moz-transform" : c,
  10446. transform : c
  10447. }
  10448. }
  10449. a.show().setStyle(e)
  10450. },
  10451. setupDragZone : function() {
  10452. var b = this, a = this.ganttView;
  10453. this.dragZone = Ext.create("Ext.dd.DragZone", this.el, {
  10454. ddGroup : this.ddGroup,
  10455. onStartDrag : function() {
  10456. this.el.addCls("sch-gantt-dep-dd-dragging");
  10457. b.fireEvent("dndstart", b);
  10458. if (b.useLineProxy) {
  10459. var c = this.dragData;
  10460. b.initLineProxy(c.sourceNode, c.isStart)
  10461. }
  10462. },
  10463. getDragData : function(g) {
  10464. var f = g.getTarget(b.terminalSelector);
  10465. if (f) {
  10466. var d = a.resolveTaskRecord(f);
  10467. if (b.fireEvent("beforednd", this, d) === false) {
  10468. return null
  10469. }
  10470. var c = !!f.className.match("sch-gantt-terminal-start"), h = Ext.core.DomHelper
  10471. .createDom({
  10472. cls : "sch-dd-dependency",
  10473. children : [{
  10474. tag : "span",
  10475. cls : "sch-dd-dependency-from",
  10476. html : Ext.String.format(
  10477. b.fromText, d.getName(), c
  10478. ? b.startText
  10479. : b.endText)
  10480. }, {
  10481. tag : "span",
  10482. cls : "sch-dd-dependency-to",
  10483. html : Ext.String.format(b.toText,
  10484. "", "")
  10485. }]
  10486. });
  10487. return {
  10488. fromId : d.getId() || d.internalId,
  10489. isStart : c,
  10490. repairXY : Ext.fly(f).getXY(),
  10491. ddel : h,
  10492. sourceNode : Ext.fly(f).up(a.eventSelector)
  10493. }
  10494. }
  10495. return false
  10496. },
  10497. afterRepair : function() {
  10498. this.el.removeCls("sch-gantt-dep-dd-dragging");
  10499. this.dragging = false;
  10500. b.fireEvent("afterdnd", this)
  10501. },
  10502. onMouseUp : function() {
  10503. this.el.removeCls("sch-gantt-dep-dd-dragging");
  10504. if (b.lineProxyEl) {
  10505. if (Ext.isIE) {
  10506. Ext.destroy(b.lineProxyEl);
  10507. b.lineProxyEl = null
  10508. } else {
  10509. b.lineProxyEl.animate({
  10510. to : {
  10511. height : 0
  10512. },
  10513. duration : 500,
  10514. callback : function() {
  10515. Ext.destroy(b.lineProxyEl);
  10516. b.lineProxyEl = null
  10517. }
  10518. })
  10519. }
  10520. }
  10521. },
  10522. getRepairXY : function() {
  10523. return this.dragData.repairXY
  10524. }
  10525. })
  10526. },
  10527. setupDropZone : function() {
  10528. var b = this, a = this.ganttView;
  10529. this.dropZone = Ext.create("Ext.dd.DropZone", this.el, {
  10530. ddGroup : this.ddGroup,
  10531. getTargetFromEvent : function(c) {
  10532. if (b.useLineProxy) {
  10533. b.updateLineProxy(c.getXY())
  10534. }
  10535. return c.getTarget(b.terminalSelector)
  10536. },
  10537. onNodeEnter : function(h, c, g, f) {
  10538. var d = h.className.match("sch-gantt-terminal-start");
  10539. Ext.fly(h).addCls(d
  10540. ? "sch-gantt-terminal-start-drophover"
  10541. : "sch-gantt-terminal-end-drophover")
  10542. },
  10543. onNodeOut : function(h, c, g, f) {
  10544. var d = h.className.match("sch-gantt-terminal-start");
  10545. Ext.fly(h).removeCls(d
  10546. ? "sch-gantt-terminal-start-drophover"
  10547. : "sch-gantt-terminal-end-drophover")
  10548. },
  10549. onNodeOver : function(k, c, j, i) {
  10550. var d = a.resolveTaskRecord(k), f = d.getId() || d.internalId, g = k.className
  10551. .match("sch-gantt-terminal-start"), h = Ext.String
  10552. .format(b.toText, d.getName(), g
  10553. ? b.startText
  10554. : b.endText);
  10555. c.proxy.el.down(".sch-dd-dependency-to").update(h);
  10556. if (b.dependencyStore.isValidDependency(i.fromId, f)) {
  10557. return this.dropAllowed
  10558. } else {
  10559. return this.dropNotAllowed
  10560. }
  10561. },
  10562. onNodeDrop : function(h, l, i, f) {
  10563. var j, c = true, d = Gnt.model.Dependency.Type, g = a
  10564. .resolveTaskRecord(h), k = g.getId() || g.internalId;
  10565. if (b.lineProxyEl) {
  10566. Ext.destroy(b.lineProxyEl);
  10567. b.lineProxyEl = null
  10568. }
  10569. this.el.removeCls("sch-gantt-dep-dd-dragging");
  10570. if (f.isStart) {
  10571. if (h.className.match("sch-gantt-terminal-start")) {
  10572. j = d.StartToStart
  10573. } else {
  10574. j = d.StartToEnd
  10575. }
  10576. } else {
  10577. if (h.className.match("sch-gantt-terminal-start")) {
  10578. j = d.EndToStart
  10579. } else {
  10580. j = d.EndToEnd
  10581. }
  10582. }
  10583. c = b.dependencyStore.isValidDependency(f.fromId, k);
  10584. if (c) {
  10585. b.fireEvent("drop", this, f.fromId, k, j)
  10586. }
  10587. b.fireEvent("afterdnd", this);
  10588. return c
  10589. }
  10590. })
  10591. }
  10592. });
  10593. Ext.define("Gnt.feature.DragCreator", {
  10594. requires : ["Ext.Template", "Sch.util.DragTracker", "Gnt.Tooltip"],
  10595. constructor : function(a) {
  10596. Ext.apply(this, a || {});
  10597. this.init()
  10598. },
  10599. disabled : false,
  10600. showDragTip : true,
  10601. dragTolerance : 2,
  10602. validatorFn : Ext.emptyFn,
  10603. validatorFnScope : null,
  10604. setDisabled : function(a) {
  10605. this.disabled = a;
  10606. if (this.dragTip) {
  10607. this.dragTip.setDisabled(a)
  10608. }
  10609. },
  10610. getProxy : function() {
  10611. if (!this.proxy) {
  10612. this.proxy = this.template.append(
  10613. this.ganttView.ownerCt.el, {}, true)
  10614. }
  10615. return this.proxy
  10616. },
  10617. onBeforeDragStart : function(f) {
  10618. var c = this.ganttView, b = f.getTarget("." + c.timeCellCls, 2);
  10619. if (b) {
  10620. var a = c.resolveTaskRecord(b);
  10621. var d = c.getDateFromDomEvent(f);
  10622. if (!this.disabled
  10623. && b
  10624. && !a.getStartDate()
  10625. && !a.getEndDate()
  10626. && c.fireEvent("beforedragcreate", c, a, d, f) !== false) {
  10627. f.stopEvent();
  10628. this.taskRecord = a;
  10629. this.originalStart = d;
  10630. this.rowRegion = c.getScheduleRegion(this.taskRecord,
  10631. this.originalStart);
  10632. this.dateConstraints = c.getDateConstraints(
  10633. this.resourceRecord, this.originalStart);
  10634. return true
  10635. }
  10636. }
  10637. return false
  10638. },
  10639. onDragStart : function() {
  10640. var c = this, a = c.ganttView, b = c.getProxy();
  10641. c.start = c.originalStart;
  10642. c.end = c.start;
  10643. c.rowBoundaries = {
  10644. top : c.rowRegion.top,
  10645. bottom : c.rowRegion.bottom
  10646. };
  10647. b.setRegion({
  10648. top : c.rowBoundaries.top,
  10649. right : c.tracker.startXY[0],
  10650. bottom : c.rowBoundaries.bottom,
  10651. left : c.tracker.startXY[0]
  10652. });
  10653. b.show();
  10654. c.ganttView.fireEvent("dragcreatestart", c.ganttView);
  10655. if (c.showDragTip) {
  10656. c.dragTip.update(c.start, c.end, true, this.taskRecord);
  10657. c.dragTip.enable();
  10658. c.dragTip.show(b)
  10659. }
  10660. },
  10661. onDrag : function(g) {
  10662. var d = this, c = d.ganttView, b = d.tracker.getRegion()
  10663. .constrainTo(d.rowRegion), f = c
  10664. .getStartEndDatesFromRegion(b, "round");
  10665. if (!f) {
  10666. return
  10667. }
  10668. d.start = f.start || d.start;
  10669. d.end = f.end || d.end;
  10670. var a = d.dateConstraints;
  10671. if (a) {
  10672. d.end = Sch.util.Date.constrain(d.end, a.start, a.end);
  10673. d.start = Sch.util.Date.constrain(d.start, a.start, a.end)
  10674. }
  10675. d.valid = this.validatorFn.call(d.validatorFnScope || d,
  10676. this.taskRecord, d.start, d.end, g) !== false;
  10677. if (d.showDragTip) {
  10678. d.dragTip.update(d.start, d.end, d.valid, this.taskRecord)
  10679. }
  10680. Ext.apply(b, d.rowBoundaries);
  10681. this.getProxy().setRegion(b)
  10682. },
  10683. onDragEnd : function(a) {
  10684. var b = this.ganttView;
  10685. if (this.showDragTip) {
  10686. this.dragTip.disable()
  10687. }
  10688. if (!this.start || !this.end || (this.end < this.start)) {
  10689. this.valid = false
  10690. }
  10691. if (this.valid) {
  10692. this.taskRecord.setStartEndDate(this.start, this.end);
  10693. b.fireEvent("dragcreateend", b, this.taskRecord, a)
  10694. }
  10695. this.proxy.hide();
  10696. b.fireEvent("afterdragcreate", b)
  10697. },
  10698. init : function() {
  10699. var c = this.ganttView, a = c.el, b = Ext.Function.bind;
  10700. this.lastTime = new Date();
  10701. this.template = this.template
  10702. || Ext
  10703. .create(
  10704. "Ext.Template",
  10705. '<div class="sch-gantt-dragcreator-proxy"></div>',
  10706. {
  10707. compiled : true,
  10708. disableFormats : true
  10709. });
  10710. c.on({
  10711. destroy : this.onGanttDestroy,
  10712. scope : this
  10713. });
  10714. this.tracker = new Sch.util.DragTracker({
  10715. el : a,
  10716. tolerance : this.dragTolerance,
  10717. onBeforeStart : b(this.onBeforeDragStart, this),
  10718. onStart : b(this.onDragStart, this),
  10719. onDrag : b(this.onDrag, this),
  10720. onEnd : b(this.onDragEnd, this)
  10721. });
  10722. if (this.showDragTip) {
  10723. this.dragTip = Ext.create("Gnt.Tooltip", {
  10724. mode : "duration",
  10725. cls : "sch-gantt-dragcreate-tip",
  10726. gantt : c
  10727. })
  10728. }
  10729. },
  10730. onGanttDestroy : function() {
  10731. if (this.dragTip) {
  10732. this.dragTip.destroy()
  10733. }
  10734. if (this.tracker) {
  10735. this.tracker.destroy()
  10736. }
  10737. if (this.proxy) {
  10738. Ext.destroy(this.proxy);
  10739. this.proxy = null
  10740. }
  10741. }
  10742. });
  10743. Ext.define("Gnt.feature.LabelEditor", {
  10744. extend : "Ext.Editor",
  10745. labelPosition : "",
  10746. constructor : function(b, a) {
  10747. this.ganttView = b;
  10748. this.ganttView.on("afterrender", this.onGanttRender, this);
  10749. this.callParent([a])
  10750. },
  10751. edit : function(a) {
  10752. var b = this.ganttView.getElementFromEventRecord(a)
  10753. .up(this.ganttView.eventWrapSelector);
  10754. this.record = a;
  10755. this.startEdit(b.down(this.delegate), this.dataIndex ? a
  10756. .get(this.dataIndex) : "")
  10757. },
  10758. delegate : "",
  10759. dataIndex : "",
  10760. shadow : false,
  10761. completeOnEnter : true,
  10762. cancelOnEsc : true,
  10763. ignoreNoChange : true,
  10764. onGanttRender : function(a) {
  10765. if (!this.field.width) {
  10766. this.autoSize = "width"
  10767. }
  10768. this.on({
  10769. beforestartedit : function(c, b, d) {
  10770. return a.fireEvent("labeledit_beforestartedit",
  10771. a, this.record, d, c)
  10772. },
  10773. beforecomplete : function(c, d, b) {
  10774. return a.fireEvent("labeledit_beforecomplete",
  10775. a, d, b, this.record, c)
  10776. },
  10777. complete : function(c, d, b) {
  10778. this.record.set(this.dataIndex, d);
  10779. a.fireEvent("labeledit_complete", a, d, b,
  10780. this.record, c)
  10781. },
  10782. scope : this
  10783. });
  10784. a.el.on("dblclick", function(c, b) {
  10785. this.edit(a.resolveTaskRecord(b))
  10786. }, this, {
  10787. delegate : this.delegate
  10788. })
  10789. }
  10790. });
  10791. Ext.define("Gnt.feature.ProgressBarResize", {
  10792. requires : ["Ext.ToolTip", "Ext.resizer.Resizer"],
  10793. constructor : function(a) {
  10794. Ext.apply(this, a || {});
  10795. var b = this.gantt;
  10796. b.on({
  10797. destroy : this.cleanUp,
  10798. scope : this
  10799. });
  10800. b.mon(b.el, "mousedown", this.onMouseDown, this, {
  10801. delegate : ".sch-gantt-progressbar-handle"
  10802. });
  10803. this.callParent(arguments)
  10804. },
  10805. useTooltip : true,
  10806. increment : 10,
  10807. onMouseDown : function(d, b) {
  10808. var c = this.gantt, f = c.resolveTaskRecord(b);
  10809. if (c.fireEvent("beforeprogressbarresize", c, f) !== false) {
  10810. var a = Ext.fly(b).prev(".sch-gantt-progress-bar");
  10811. d.stopEvent();
  10812. this.createResizable(a, f, d);
  10813. c.fireEvent("progressbarresizestart", c, f)
  10814. }
  10815. },
  10816. createResizable : function(d, a, h) {
  10817. var c = h.getTarget(), i = d.up(this.gantt.eventSelector), g = i
  10818. .getWidth()
  10819. - 4, b = g * this.increment / 100;
  10820. var f = Ext.create("Ext.resizer.Resizer", {
  10821. target : d,
  10822. taskRecord : a,
  10823. handles : "e",
  10824. minWidth : 0,
  10825. maxWidth : g,
  10826. minHeight : 1,
  10827. widthIncrement : b,
  10828. listeners : {
  10829. resizedrag : this.partialResize,
  10830. resize : this.afterResize,
  10831. scope : this
  10832. }
  10833. });
  10834. f.resizeTracker.onMouseDown(h, f.east.dom);
  10835. i
  10836. .select(".x-resizable-handle, .sch-gantt-terminal, .sch-gantt-progressbar-handle")
  10837. .hide();
  10838. if (this.useTooltip) {
  10839. if (!this.tip) {
  10840. this.tip = Ext.create("Ext.ToolTip", {
  10841. autoHide : false,
  10842. anchor : "b",
  10843. html : "%"
  10844. })
  10845. }
  10846. this.tip.setTarget(d);
  10847. this.tip.show();
  10848. this.tip.body.update(a.getPercentDone() + "%")
  10849. }
  10850. },
  10851. partialResize : function(c, b) {
  10852. var a = Math.round(b * 100 / (c.maxWidth * this.increment))
  10853. * this.increment;
  10854. if (this.tip) {
  10855. this.tip.body.update(a + "%")
  10856. }
  10857. },
  10858. afterResize : function(d, a, b, f) {
  10859. var g = d.taskRecord;
  10860. if (this.tip) {
  10861. this.tip.hide()
  10862. }
  10863. var c = Math.round(a * 100 / (d.maxWidth * this.increment))
  10864. * this.increment;
  10865. d.taskRecord.setPercentDone(c);
  10866. d.destroy();
  10867. this.gantt.fireEvent("afterprogressbarresize", this.gantt, g)
  10868. },
  10869. cleanUp : function() {
  10870. if (this.tip) {
  10871. this.tip.destroy()
  10872. }
  10873. }
  10874. });
  10875. Ext.define("Gnt.feature.TaskResize", {
  10876. constructor : function(a) {
  10877. Ext.apply(this, a);
  10878. var b = this.gantt;
  10879. b.on({
  10880. destroy : this.cleanUp,
  10881. scope : this
  10882. });
  10883. b.mon(b.el, "mousedown", this.onMouseDown, this, {
  10884. delegate : ".sch-resizable-handle"
  10885. });
  10886. this.callParent(arguments)
  10887. },
  10888. showDuration : true,
  10889. useTooltip : true,
  10890. validatorFn : Ext.emptyFn,
  10891. validatorFnScope : null,
  10892. onMouseDown : function(f) {
  10893. var b = this.gantt, a = f.getTarget(b.eventSelector), g = b
  10894. .resolveTaskRecord(a);
  10895. var c = a.className.match("start") ? "west" : "east";
  10896. var d = g.isResizable();
  10897. if (d === false || typeof d === "string" && !a.className.match(d)) {
  10898. return
  10899. }
  10900. if (b.fireEvent("beforetaskresize", b, g, f) === false) {
  10901. return
  10902. }
  10903. f.stopEvent();
  10904. this.createResizable(Ext.get(a), g, f);
  10905. b.fireEvent("taskresizestart", b, g)
  10906. },
  10907. createResizable : function(c, k, j) {
  10908. var m = j.getTarget(), i = this.gantt, a = !!m.className
  10909. .match("sch-resizable-handle-west"), d = i.getSnapPixelAmount(), f = c
  10910. .getWidth(), l = c.up(".x-grid-row").getRegion();
  10911. this.resizable = Ext.create("Ext.resizer.Resizer", {
  10912. startLeft : c.getLeft(),
  10913. startRight : c.getRight(),
  10914. target : c,
  10915. taskRecord : k,
  10916. handles : a ? "w" : "e",
  10917. constrainTo : l,
  10918. minHeight : 1,
  10919. minWidth : d,
  10920. widthIncrement : d,
  10921. listeners : {
  10922. resizedrag : this[a ? "partialWestResize" : "partialEastResize"],
  10923. resize : this.afterResize,
  10924. scope : this
  10925. }
  10926. });
  10927. this.resizable.resizeTracker.onMouseDown(j, this.resizable[a
  10928. ? "west"
  10929. : "east"].dom);
  10930. if (this.useTooltip) {
  10931. if (!this.tip) {
  10932. this.tip = Ext.create("Gnt.Tooltip", {
  10933. mode : this.showDuration ? "duration" : "startend",
  10934. gantt : this.gantt
  10935. })
  10936. }
  10937. var b = k.getStartDate(), h = k.getEndDate();
  10938. this.tip.show(c);
  10939. this.tip.update(b, h, true, k)
  10940. }
  10941. },
  10942. partialEastResize : function(i, f, b, g) {
  10943. var c = this.gantt, a = c.getDateFromXY([
  10944. i.startLeft + Math.min(f, this.resizable.maxWidth), 0],
  10945. "round");
  10946. if (!a || i.end - a === 0) {
  10947. return
  10948. }
  10949. var h = i.taskRecord.getStartDate(), d = this.validatorFn.call(
  10950. this.validatorFnScope || this, i.taskRecord, h, a) !== false;
  10951. i.end = a;
  10952. c.fireEvent("partialtaskresize", c, i.taskRecord, h, a, i.el, g);
  10953. if (this.useTooltip) {
  10954. this.tip.update(h, a, d, i.taskRecord)
  10955. }
  10956. },
  10957. partialWestResize : function(i, f, b, g) {
  10958. var c = this.gantt, h = c.getDateFromXY(
  10959. [i.startRight - Math.min(f, this.resizable.maxWidth), 0],
  10960. "round");
  10961. if (!h || i.start - h === 0) {
  10962. return
  10963. }
  10964. var a = i.taskRecord.getEndDate(), d = this.validatorFn.call(
  10965. this.validatorFnScope || this, i.taskRecord, h, a) !== false;
  10966. i.start = h;
  10967. c.fireEvent("partialtaskresize", c, i.taskRecord, h, a, i.el, g);
  10968. if (this.useTooltip) {
  10969. this.tip.update(h, a, d, i.taskRecord)
  10970. }
  10971. },
  10972. afterResize : function(a, l, i, j) {
  10973. if (this.useTooltip) {
  10974. this.tip.hide()
  10975. }
  10976. var k = a.taskRecord, g = k.getStartDate(), m = k.getEndDate(), c = a.start
  10977. || g, f = a.end || m, d = this.gantt;
  10978. a.destroy();
  10979. if (c
  10980. && f
  10981. && (c - g || f - m)
  10982. && this.validatorFn.call(this.validatorFnScope || this, k, c,
  10983. f, j) !== false) {
  10984. var b = this.gantt.taskStore.skipWeekendsDuringDragDrop;
  10985. if (c - g !== 0) {
  10986. k.setStartDate(c <= f ? c : f, false, b)
  10987. } else {
  10988. k.setEndDate(c <= f ? f : c, false, b)
  10989. }
  10990. } else {
  10991. d.refreshKeepingScroll()
  10992. }
  10993. d.fireEvent("aftertaskresize", d, k)
  10994. },
  10995. cleanUp : function() {
  10996. if (this.tip) {
  10997. this.tip.destroy()
  10998. }
  10999. }
  11000. });
  11001. Ext.define("Gnt.feature.WorkingTime", {
  11002. extend : "Sch.plugin.Zones",
  11003. requires : ["Ext.data.Store", "Sch.model.Range"],
  11004. expandToFitView : true,
  11005. calendar : null,
  11006. init : function(a) {
  11007. if (!this.calendar) {
  11008. Ext.Error
  11009. .raise("Required attribute 'calendar' missed during initialization of 'Gnt.feature.WorkingTime'")
  11010. }
  11011. this.bindCalendar(this.calendar);
  11012. Ext.apply(this, {
  11013. store : new Ext.data.Store({
  11014. model : "Sch.model.Range"
  11015. })
  11016. });
  11017. this.callParent(arguments);
  11018. a.on("viewchange", this.onViewChange, this);
  11019. this.onViewChange()
  11020. },
  11021. bindCalendar : function(b) {
  11022. var a = {
  11023. datachanged : this.refresh,
  11024. update : this.refresh,
  11025. scope : this,
  11026. delay : 1
  11027. };
  11028. if (this.calendar) {
  11029. this.calendar.un(a)
  11030. }
  11031. b.on(a);
  11032. this.calendar = b
  11033. },
  11034. onViewChange : function() {
  11035. var a = Sch.util.Date;
  11036. if (a.compareUnits(this.timeAxis.unit, a.WEEK) > 0) {
  11037. this.setDisabled(true)
  11038. } else {
  11039. this.setDisabled(false);
  11040. this.refresh()
  11041. }
  11042. },
  11043. refresh : function() {
  11044. var a = this.schedulerView;
  11045. this.store.removeAll(true);
  11046. this.store.add(this.calendar.getHolidaysRanges(a.getStart(),
  11047. a.getEnd(), true))
  11048. }
  11049. });
  11050. Ext.define("Gnt.plugin.DependencyEditor", {
  11051. extend : "Ext.form.FormPanel",
  11052. mixins : ["Ext.AbstractPlugin"],
  11053. lockableScope : "normal",
  11054. requires : ["Ext.form.DisplayField", "Ext.form.ComboBox",
  11055. "Ext.form.NumberField", "Gnt.model.Dependency"],
  11056. hideOnBlur : true,
  11057. fromText : "From",
  11058. toText : "To",
  11059. typeText : "Type",
  11060. lagText : "Lag",
  11061. endToStartText : "Finish-To-Start",
  11062. startToStartText : "Start-To-Start",
  11063. endToEndText : "Finish-To-Finish",
  11064. startToEndText : "Start-To-Finish",
  11065. showLag : false,
  11066. border : false,
  11067. height : 150,
  11068. width : 260,
  11069. frame : true,
  11070. labelWidth : 60,
  11071. constrain : false,
  11072. initComponent : function() {
  11073. Ext.apply(this, {
  11074. items : this.buildFields(),
  11075. defaults : {
  11076. width : 240
  11077. },
  11078. floating : true,
  11079. hideMode : "offsets"
  11080. });
  11081. this.callParent(arguments)
  11082. },
  11083. beforeRender : function() {
  11084. this.addCls("sch-gantt-dependencyeditor");
  11085. this.callParent(arguments)
  11086. },
  11087. init : function(a) {
  11088. a.on({
  11089. dependencydblclick : this.onDependencyDblClick,
  11090. destroy : this.destroy,
  11091. scope : this
  11092. });
  11093. a.on("afterrender", this.onGanttRender, this, {
  11094. delay : 50
  11095. });
  11096. this.gantt = a;
  11097. this.taskStore = a.getTaskStore()
  11098. },
  11099. onGanttRender : function() {
  11100. this.render(Ext.getBody());
  11101. this.collapse(Ext.Component.DIRECTION_TOP, true);
  11102. this.hide();
  11103. if (this.hideOnBlur) {
  11104. this.mon(Ext.getBody(), "click", this.onMouseClick, this)
  11105. }
  11106. },
  11107. show : function(a, b) {
  11108. this.dependencyRecord = a;
  11109. this.getForm().loadRecord(a);
  11110. this.fromLabel
  11111. .setValue(this.dependencyRecord.getSourceTask().getName());
  11112. this.toLabel.setValue(this.dependencyRecord.getTargetTask().getName());
  11113. this.callParent([]);
  11114. this.el.setXY(b);
  11115. this.expand(!this.constrain);
  11116. if (this.constrain) {
  11117. this.doConstrain(Ext.util.Region.getRegion(Ext.getBody()))
  11118. }
  11119. },
  11120. buildFields : function() {
  11121. var c = this, d = Gnt.model.Dependency, b = d.Type, a = [
  11122. this.fromLabel = Ext.create("Ext.form.DisplayField", {
  11123. fieldLabel : this.fromText
  11124. }),
  11125. this.toLabel = Ext.create("Ext.form.DisplayField", {
  11126. fieldLabel : this.toText
  11127. }), this.typeField = Ext.create("Ext.form.ComboBox", {
  11128. name : d.prototype.nameField,
  11129. fieldLabel : this.typeText,
  11130. triggerAction : "all",
  11131. queryMode : "local",
  11132. valueField : "value",
  11133. displayField : "text",
  11134. editable : false,
  11135. store : Ext.create("Ext.data.JsonStore", {
  11136. fields : ["text", "value"],
  11137. data : [{
  11138. text : this.endToStartText,
  11139. value : b.EndToStart
  11140. }, {
  11141. text : this.startToStartText,
  11142. value : b.StartToStart
  11143. }, {
  11144. text : this.endToEndText,
  11145. value : b.EndToEnd
  11146. }, {
  11147. text : this.startToEndText,
  11148. value : b.StartToEnd
  11149. }]
  11150. })
  11151. })];
  11152. if (this.showLag) {
  11153. a.push(this.lagField = Ext.create("Ext.form.NumberField", {
  11154. name : d.prototype.lagField,
  11155. fieldLabel : this.lagText
  11156. }))
  11157. }
  11158. return a
  11159. },
  11160. onDependencyDblClick : function(c, a, d, b) {
  11161. if (this.lagField) {
  11162. this.lagField.name = a.lagField
  11163. }
  11164. if (this.typeField) {
  11165. this.typeField.name = a.typeField
  11166. }
  11167. if (a != this.dependencyRecord) {
  11168. this.show(a, d.getXY())
  11169. }
  11170. },
  11171. onMouseClick : function(a) {
  11172. if (this.collapsed || a.within(this.getEl()) || a.getTarget(".x-layer")
  11173. || a.getTarget(".sch-ignore-click")) {
  11174. return
  11175. }
  11176. this.collapse()
  11177. },
  11178. afterCollapse : function() {
  11179. delete this.dependencyRecord;
  11180. this.hide();
  11181. this.callParent(arguments)
  11182. }
  11183. });
  11184. Ext.define("Gnt.plugin.TaskContextMenu", {
  11185. extend : "Ext.menu.Menu",
  11186. mixins : ["Ext.AbstractPlugin"],
  11187. lockableScope : "top",
  11188. requires : ["Gnt.model.Dependency"],
  11189. plain : true,
  11190. triggerEvent : "taskcontextmenu",
  11191. texts : {
  11192. newTaskText : "New task",
  11193. newMilestoneText : "New milestone",
  11194. deleteTask : "Delete task(s)",
  11195. editLeftLabel : "Edit left label",
  11196. editRightLabel : "Edit right label",
  11197. add : "Add...",
  11198. deleteDependency : "Delete dependency...",
  11199. addTaskAbove : "Task above",
  11200. addTaskBelow : "Task below",
  11201. addMilestone : "Milestone",
  11202. addSubtask : "Sub-task",
  11203. addSuccessor : "Successor",
  11204. addPredecessor : "Predecessor"
  11205. },
  11206. grid : null,
  11207. rec : null,
  11208. lastHighlightedItem : null,
  11209. createMenuItems : function() {
  11210. var a = this.texts;
  11211. return [{
  11212. handler : this.deleteTask,
  11213. requiresTask : true,
  11214. scope : this,
  11215. text : a.deleteTask
  11216. }, {
  11217. handler : this.editLeftLabel,
  11218. requiresTask : true,
  11219. scope : this,
  11220. text : a.editLeftLabel
  11221. }, {
  11222. handler : this.editRightLabel,
  11223. requiresTask : true,
  11224. scope : this,
  11225. text : a.editRightLabel
  11226. }, {
  11227. text : a.add,
  11228. menu : {
  11229. plain : true,
  11230. items : [{
  11231. handler : this.addTaskAboveAction,
  11232. requiresTask : true,
  11233. scope : this,
  11234. text : a.addTaskAbove
  11235. }, {
  11236. handler : this.addTaskBelowAction,
  11237. scope : this,
  11238. text : a.addTaskBelow
  11239. }, {
  11240. handler : this.addMilestone,
  11241. requiresTask : true,
  11242. scope : this,
  11243. text : a.addMilestone
  11244. }, {
  11245. handler : this.addSubtask,
  11246. requiresTask : true,
  11247. scope : this,
  11248. text : a.addSubtask
  11249. }, {
  11250. handler : this.addSuccessor,
  11251. requiresTask : true,
  11252. scope : this,
  11253. text : a.addSuccessor
  11254. }, {
  11255. handler : this.addPredecessor,
  11256. requiresTask : true,
  11257. scope : this,
  11258. text : a.addPredecessor
  11259. }]
  11260. }
  11261. }, {
  11262. text : a.deleteDependency,
  11263. requiresTask : true,
  11264. isDependenciesMenu : true,
  11265. menu : {
  11266. plain : true,
  11267. listeners : {
  11268. beforeshow : this.populateDependencyMenu,
  11269. mouseover : this.onDependencyMouseOver,
  11270. mouseleave : this.onDependencyMouseOut,
  11271. scope : this
  11272. }
  11273. }
  11274. }]
  11275. },
  11276. buildMenuItems : function() {
  11277. this.items = this.createMenuItems()
  11278. },
  11279. initComponent : function() {
  11280. this.buildMenuItems();
  11281. this.callParent(arguments)
  11282. },
  11283. init : function(b) {
  11284. b.on("destroy", this.cleanUp, this);
  11285. var a = b.getSchedulingView(), c = b.lockedGrid.getView();
  11286. if (this.triggerEvent === "itemcontextmenu") {
  11287. c.on("itemcontextmenu", this.onItemContextMenu, this);
  11288. a.on("itemcontextmenu", this.onItemContextMenu, this)
  11289. }
  11290. a.on("taskcontextmenu", this.onTaskContextMenu, this);
  11291. a.on("containercontextmenu", this.onContainerContextMenu, this);
  11292. c.on("containercontextmenu", this.onContainerContextMenu, this);
  11293. this.grid = b
  11294. },
  11295. populateDependencyMenu : function(f) {
  11296. var d = this.grid, b = d.getTaskStore(), e = this.rec
  11297. .getAllDependencies(), a = d.dependencyStore;
  11298. f.removeAll();
  11299. if (e.length === 0) {
  11300. return false
  11301. }
  11302. var c = this.rec.getId() || this.rec.internalId;
  11303. Ext.each(e, function(i) {
  11304. var h = i.getSourceId(), g = b.getById(h == c ? i
  11305. .getTargetId() : h);
  11306. if (g) {
  11307. f.add({
  11308. depId : i.internalId,
  11309. text : Ext.util.Format.ellipsis(
  11310. g.getName(), 30),
  11311. scope : this,
  11312. handler : function(k) {
  11313. var j;
  11314. a.each(function(l) {
  11315. if (l.internalId == k.depId) {
  11316. j = l;
  11317. return false
  11318. }
  11319. });
  11320. a.remove(j)
  11321. }
  11322. })
  11323. }
  11324. }, this)
  11325. },
  11326. onDependencyMouseOver : function(d, a, b) {
  11327. if (a) {
  11328. var c = this.grid.getSchedulingView();
  11329. if (this.lastHighlightedItem) {
  11330. c.unhighlightDependency(this.lastHighlightedItem.depId)
  11331. }
  11332. this.lastHighlightedItem = a;
  11333. c.highlightDependency(a.depId)
  11334. }
  11335. },
  11336. onDependencyMouseOut : function(b, a) {
  11337. if (this.lastHighlightedItem) {
  11338. this.grid.getSchedulingView()
  11339. .unhighlightDependency(this.lastHighlightedItem.depId)
  11340. }
  11341. },
  11342. cleanUp : function() {
  11343. this.destroy()
  11344. },
  11345. onTaskContextMenu : function(b, a, c) {
  11346. this.activateMenu(a, c)
  11347. },
  11348. onItemContextMenu : function(b, a, d, c, f) {
  11349. this.activateMenu(a, f)
  11350. },
  11351. onContainerContextMenu : function(a, b) {
  11352. this.activateMenu(null, b)
  11353. },
  11354. activateMenu : function(b, a) {
  11355. if (this.grid.isReadOnly()) {
  11356. return
  11357. }
  11358. a.stopEvent();
  11359. this.rec = b;
  11360. this.configureMenuItems();
  11361. this.showAt(a.getXY())
  11362. },
  11363. configureMenuItems : function() {
  11364. var b = this.query("[requiresTask]");
  11365. var c = this.rec;
  11366. Ext.each(b, function(d) {
  11367. d.setDisabled(!c)
  11368. });
  11369. var a = this.query("[isDependenciesMenu]")[0];
  11370. if (c && a) {
  11371. a.setDisabled(!c.getAllDependencies().length)
  11372. }
  11373. },
  11374. copyTask : function(c) {
  11375. var b = this.grid.getTaskStore().model;
  11376. var a = new b({
  11377. leaf : true
  11378. });
  11379. a.setPercentDone(0);
  11380. a.setName(this.texts.newTaskText);
  11381. a.set(a.startDateField, (c && c.getStartDate()) || null);
  11382. a.set(a.endDateField, (c && c.getEndDate()) || null);
  11383. a.set(a.durationField, (c && c.getDuration()) || null);
  11384. a.set(a.durationUnitField, (c && c.getDurationUnit()) || "d");
  11385. return a
  11386. },
  11387. addTaskAbove : function(a) {
  11388. var b = this.rec;
  11389. if (b) {
  11390. b.addTaskAbove(a)
  11391. } else {
  11392. this.grid.taskStore.getRootNode().appendChild(a)
  11393. }
  11394. },
  11395. addTaskBelow : function(a) {
  11396. var b = this.rec;
  11397. if (b) {
  11398. b.addTaskBelow(a)
  11399. } else {
  11400. this.grid.taskStore.getRootNode().appendChild(a)
  11401. }
  11402. },
  11403. deleteTask : function() {
  11404. var a = this.grid.getSelectionModel().selected;
  11405. this.grid.taskStore.remove(a.items)
  11406. },
  11407. editLeftLabel : function() {
  11408. this.grid.getSchedulingView().editLeftLabel(this.rec)
  11409. },
  11410. editRightLabel : function() {
  11411. this.grid.getSchedulingView().editRightLabel(this.rec)
  11412. },
  11413. addTaskAboveAction : function() {
  11414. this.addTaskAbove(this.copyTask(this.rec))
  11415. },
  11416. addTaskBelowAction : function() {
  11417. this.addTaskBelow(this.copyTask(this.rec))
  11418. },
  11419. addSubtask : function() {
  11420. var a = this.rec;
  11421. a.addSubtask(this.copyTask(a))
  11422. },
  11423. addSuccessor : function() {
  11424. var a = this.rec;
  11425. a.addSuccessor(this.copyTask(a))
  11426. },
  11427. addPredecessor : function() {
  11428. var a = this.rec;
  11429. a.addPredecessor(this.copyTask(a))
  11430. },
  11431. addMilestone : function() {
  11432. var b = this.rec, a = this.copyTask(b);
  11433. b.addTaskBelow(a);
  11434. a.setStartEndDate(b.getEndDate(), b.getEndDate())
  11435. }
  11436. });
  11437. Ext.define("Gnt.plugin.Export", {
  11438. extend : "Sch.plugin.PdfExport",
  11439. alternateClassName : "Gnt.plugin.PdfExport",
  11440. showExportDialog : function() {
  11441. this.exportDialogConfig.scrollerDisabled = true;
  11442. this.callParent(arguments)
  11443. },
  11444. getExportJsonHtml : function(d, g) {
  11445. var b = this.scheduler.getSchedulingView(), c = b.dependencyView, a = c.painter
  11446. .getDependencyTplData(b.dependencyStore.getRange()), e = c.lineTpl
  11447. .apply(a), f = {
  11448. dependencies : e,
  11449. rowsAmount : d.rowsAmount,
  11450. columnsAmountNormal : d.columnsAmountNormal,
  11451. columnsAmountLocked : d.columnsAmountLocked,
  11452. timeColumnWidth : d.timeColumnWidth,
  11453. lockedGridWidth : d.lockedGridWidth,
  11454. rowHeight : d.rowHeight
  11455. };
  11456. d.panelHTML = f;
  11457. return this.callParent(arguments)
  11458. },
  11459. resizePanelHTML : function(e) {
  11460. var f = this.callParent(arguments), b = f
  11461. .select(".sch-dependencyview-ct").first(), d = e.k
  11462. * e.rowsAmount * e.rowHeight, c = e.i * e.timeColumnWidth
  11463. * (e.i === 1 ? e.columnsAmountLocked : e.columnsAmountNormal);
  11464. b.dom.innerHTML = e.dependencies;
  11465. b.applyStyles({
  11466. top : -d + "px",
  11467. left : -c + "px"
  11468. });
  11469. var a = f.select(".x-splitter").first();
  11470. a.setHeight("100%");
  11471. return f
  11472. }
  11473. });
  11474. Ext.define("Gnt.plugin.Printable", {
  11475. extend : "Sch.plugin.Printable",
  11476. getGridContent : function(e) {
  11477. var a = this.callParent(arguments), j = e.getSchedulingView(), h = j.dependencyView, n = h.painter
  11478. .getDependencyTplData(j.dependencyStore.getRange()), d = h.lineTpl
  11479. .apply(n), m = a.normalRows;
  11480. if (Ext.select(".sch-gantt-critical-chain").first()) {
  11481. var b = Ext.DomHelper.createDom({
  11482. tag : "div",
  11483. html : d
  11484. });
  11485. b = Ext.get(b);
  11486. var p = Ext.DomHelper.createDom({
  11487. tag : "div",
  11488. html : m
  11489. });
  11490. p = Ext.get(p);
  11491. var q = j.getCriticalPaths(), c = j.dependencyStore, o, g, f, k;
  11492. Ext.each(q, function(i) {
  11493. for (g = 0, f = i.length; g < f; g++) {
  11494. o = i[g];
  11495. this.highlightTask(o, e, p);
  11496. if (g < (f - 1)) {
  11497. k = c.getAt(c.findBy(function(l) {
  11498. return l.getTargetId() === (o.getId() || o.internalId)
  11499. && l.getSourceId() === (i[g + 1].getId() || i[g
  11500. + 1].internalId)
  11501. }));
  11502. this.highlightDependency(k, b, h)
  11503. }
  11504. }
  11505. }, this);
  11506. m = p.getHTML();
  11507. d = b.getHTML()
  11508. }
  11509. a.normalRows = d + m;
  11510. return a
  11511. },
  11512. highlightTask : function(b, a, e) {
  11513. var d = a.getSchedulingView().getElementFromEventRecord(b), c = d.id;
  11514. if (d) {
  11515. e.select("#" + c).first().parent("tr")
  11516. .addCls("sch-gantt-task-highlighted")
  11517. }
  11518. },
  11519. highlightDependency : function(c, b, a) {
  11520. var d = c instanceof Ext.data.Model ? c.internalId : c;
  11521. return b.select(".sch-dep-" + d).addCls(a.selectedCls)
  11522. }
  11523. });
  11524. Ext.define("Gnt.view.DependencyPainter", {
  11525. requires : ["Ext.util.Region"],
  11526. constructor : function(a) {
  11527. a = a || {};
  11528. Ext.apply(this, a, {
  11529. xOffset : 8,
  11530. yOffset : 7,
  11531. midRowOffset : 6,
  11532. arrowOffset : 8
  11533. })
  11534. },
  11535. getTaskBox : function(q) {
  11536. var h = Sch.util.Date, j = q.getStartDate(), p = q.getEndDate(), m = this.ganttView, d = m
  11537. .getStart(), c = m.getEnd();
  11538. if (!q.isVisible() || !j || !p || !h.intersectSpans(j, p, d, c)) {
  11539. return null
  11540. }
  11541. var e, l = this.taskStore.buffered, b = m.getXYFromDate(h.max(j, d))[0], r = m
  11542. .getXYFromDate(h.min(p, c))[0], a = m.getNodeByRecord(q);
  11543. if (a || l) {
  11544. var t = m.getXOffset(q), n, i, v = q.isMilestone(), u = true;
  11545. if (b > t) {
  11546. b -= t
  11547. }
  11548. r += t - 1;
  11549. if (!v && Ext.isIE) {
  11550. if ((Ext.isIE7 || Ext.isIE6) && !Ext.isIEQuirks) {
  11551. r += 5;
  11552. b -= 2
  11553. } else {
  11554. if ((Ext.isIE6 || Ext.isIE7 || Ext.isIE8) && Ext.isIEQuirks) {
  11555. r += 1;
  11556. b -= 2
  11557. }
  11558. }
  11559. }
  11560. var g = m.el;
  11561. var k = g.getScroll().top;
  11562. if (a) {
  11563. var s = m.getEventNodeByRecord(q);
  11564. if (v) {
  11565. e = Ext.fly(a).getOffsetsTo(g);
  11566. n = e[1] + k;
  11567. i = n + Ext.fly(a).getHeight()
  11568. } else {
  11569. e = Ext.fly(s).getOffsetsTo(g);
  11570. n = e[1] + k;
  11571. i = n + Ext.fly(s).getHeight()
  11572. }
  11573. } else {
  11574. var f = m.store.first();
  11575. var o = m.all.elements;
  11576. if (!f) {
  11577. return null
  11578. }
  11579. if (q.isAbove(f)) {
  11580. a = o[0];
  11581. e = Ext.fly(a).getOffsetsTo(g);
  11582. e[1] -= m.rowHeight
  11583. } else {
  11584. a = o[o.length - 1];
  11585. e = Ext.fly(a).getOffsetsTo(g);
  11586. e[1] += m.rowHeight
  11587. }
  11588. n = e[1] + k;
  11589. i = n + this.rowHeight;
  11590. u = false
  11591. }
  11592. return {
  11593. top : n,
  11594. right : r,
  11595. bottom : i,
  11596. left : b,
  11597. rendered : u
  11598. }
  11599. }
  11600. },
  11601. getRenderData : function(f) {
  11602. var e = f.getSourceTask(), c = f.getTargetTask();
  11603. if (!e || !c) {
  11604. return null
  11605. }
  11606. var a = this.getTaskBox(e);
  11607. var d = this.getTaskBox(c);
  11608. if (this.taskStore.buffered && a && !a.rendered && d && !d.rendered) {
  11609. var g = this.ganttView.store.first();
  11610. var b = this.ganttView.store.last();
  11611. if ((e.isAbove(g) && c.isAbove(g))
  11612. || (b.isAbove(e) && b.isAbove(c))) {
  11613. return null
  11614. }
  11615. }
  11616. return {
  11617. fromBox : a,
  11618. toBox : d
  11619. }
  11620. },
  11621. getDependencyTplData : function(q) {
  11622. var n = this, j = n.taskStore;
  11623. if (!Ext.isArray(q)) {
  11624. q = [q]
  11625. }
  11626. if (q.length === 0 || j.getCount() <= 0) {
  11627. return
  11628. }
  11629. var b = [], a = Gnt.model.Dependency.Type, o = n.ganttView, p, k, g, m, h, c;
  11630. for (var f = 0, d = q.length; f < d; f++) {
  11631. c = q[f];
  11632. var e = this.getRenderData(c);
  11633. if (e) {
  11634. m = e.fromBox;
  11635. h = e.toBox;
  11636. if (m && h) {
  11637. switch (c.getType()) {
  11638. case a.StartToEnd :
  11639. p = n.getStartToEndCoordinates(m, h, c);
  11640. break;
  11641. case a.StartToStart :
  11642. p = n.getStartToStartCoordinates(m, h, c);
  11643. break;
  11644. case a.EndToStart :
  11645. p = n.getEndToStartCoordinates(m, h, c);
  11646. break;
  11647. case a.EndToEnd :
  11648. p = n.getEndToEndCoordinates(m, h, c);
  11649. break;
  11650. default :
  11651. throw "Invalid dependency type: " + c.getType()
  11652. }
  11653. if (p) {
  11654. b.push({
  11655. lineCoordinates : p,
  11656. id : c.internalId,
  11657. cls : c.getCls()
  11658. })
  11659. }
  11660. }
  11661. }
  11662. }
  11663. return b
  11664. },
  11665. getStartToStartCoordinates : function(e, d, c) {
  11666. var b = e.left, g = e.top - 1 + ((e.bottom - e.top) / 2), a = d.left, f = d.top
  11667. - 1 + ((d.bottom - d.top) / 2), h = e.top < d.top
  11668. ? (f - this.yOffset - this.midRowOffset)
  11669. : (f + this.yOffset + this.midRowOffset), i = this.xOffset
  11670. + this.arrowOffset;
  11671. if (b > (a + this.xOffset)) {
  11672. i += (b - a)
  11673. }
  11674. return [{
  11675. x1 : b,
  11676. y1 : g,
  11677. x2 : b - i,
  11678. y2 : g
  11679. }, {
  11680. x1 : b - i,
  11681. y1 : g,
  11682. x2 : b - i,
  11683. y2 : f
  11684. }, {
  11685. x1 : b - i,
  11686. y1 : f,
  11687. x2 : a - this.arrowOffset,
  11688. y2 : f
  11689. }]
  11690. },
  11691. getStartToEndCoordinates : function(g, f, e) {
  11692. var c = g.left, j = g.top - 1 + ((g.bottom - g.top) / 2), a = f.right, h = f.top
  11693. - 1 + ((f.bottom - f.top) / 2), k = g.top < f.top
  11694. ? (h - this.yOffset - this.midRowOffset)
  11695. : (h + this.yOffset + this.midRowOffset), i, b;
  11696. if (a > (c + this.xOffset - this.arrowOffset)
  11697. || Math.abs(a - c) < (2 * (this.xOffset + this.arrowOffset))) {
  11698. b = c - this.xOffset - this.arrowOffset;
  11699. var d = a + this.xOffset + this.arrowOffset;
  11700. i = [{
  11701. x1 : c,
  11702. y1 : j,
  11703. x2 : b,
  11704. y2 : j
  11705. }, {
  11706. x1 : b,
  11707. y1 : j,
  11708. x2 : b,
  11709. y2 : k
  11710. }, {
  11711. x1 : b,
  11712. y1 : k,
  11713. x2 : d,
  11714. y2 : k
  11715. }, {
  11716. x1 : d,
  11717. y1 : k,
  11718. x2 : d,
  11719. y2 : h
  11720. }, {
  11721. x1 : d,
  11722. y1 : h,
  11723. x2 : a + this.arrowOffset,
  11724. y2 : h
  11725. }]
  11726. } else {
  11727. b = c - this.xOffset - this.arrowOffset;
  11728. i = [{
  11729. x1 : c,
  11730. y1 : j,
  11731. x2 : b,
  11732. y2 : j
  11733. }, {
  11734. x1 : b,
  11735. y1 : j,
  11736. x2 : b,
  11737. y2 : h
  11738. }, {
  11739. x1 : b,
  11740. y1 : h,
  11741. x2 : a + this.arrowOffset,
  11742. y2 : h
  11743. }]
  11744. }
  11745. return i
  11746. },
  11747. getEndToStartCoordinates : function(g, f, e) {
  11748. var c = g.right, j = g.top - 1 + ((g.bottom - g.top) / 2), a = f.left, h = f.top
  11749. - 1 + ((f.bottom - f.top) / 2), k = g.top < f.top
  11750. ? (h - this.yOffset - this.midRowOffset)
  11751. : (h + this.yOffset + this.midRowOffset), i, b;
  11752. if (a >= (c - 6) && h > j) {
  11753. b = Math.max(c - 6, a) + this.xOffset - 2;
  11754. h = f.top
  11755. + (e.getTargetTask().isMilestone()
  11756. ? this.rowHeight * 0.18
  11757. : 0);
  11758. i = [{
  11759. x1 : c,
  11760. y1 : j,
  11761. x2 : b,
  11762. y2 : j
  11763. }, {
  11764. x1 : b,
  11765. y1 : j,
  11766. x2 : b,
  11767. y2 : h - this.arrowOffset
  11768. }]
  11769. } else {
  11770. b = c + this.xOffset + this.arrowOffset;
  11771. var d = a - this.xOffset - this.arrowOffset;
  11772. if (h > j || a < (c + 2 * this.arrowOffset)) {
  11773. i = [{
  11774. x1 : c,
  11775. y1 : j,
  11776. x2 : b,
  11777. y2 : j
  11778. }, {
  11779. x1 : b,
  11780. y1 : j,
  11781. x2 : b,
  11782. y2 : k
  11783. }, {
  11784. x1 : b,
  11785. y1 : k,
  11786. x2 : d,
  11787. y2 : k
  11788. }, {
  11789. x1 : d,
  11790. y1 : k,
  11791. x2 : d,
  11792. y2 : h
  11793. }, {
  11794. x1 : d,
  11795. y1 : h,
  11796. x2 : a - this.arrowOffset,
  11797. y2 : h
  11798. }]
  11799. } else {
  11800. i = [{
  11801. x1 : c,
  11802. y1 : j,
  11803. x2 : d,
  11804. y2 : j
  11805. }, {
  11806. x1 : d,
  11807. y1 : j,
  11808. x2 : d,
  11809. y2 : h
  11810. }, {
  11811. x1 : d,
  11812. y1 : h,
  11813. x2 : a - this.arrowOffset,
  11814. y2 : h
  11815. }]
  11816. }
  11817. }
  11818. return i
  11819. },
  11820. getEndToEndCoordinates : function(a, c, e) {
  11821. var d = a.right, g = a.top - 1 + ((a.bottom - a.top) / 2), b = c.right
  11822. + this.arrowOffset, f = c.top - 1 + ((c.bottom - c.top) / 2), h = b
  11823. + this.xOffset + this.arrowOffset;
  11824. if (d > (b + this.xOffset)) {
  11825. h += d - b
  11826. }
  11827. return [{
  11828. x1 : d,
  11829. y1 : g,
  11830. x2 : h,
  11831. y2 : g
  11832. }, {
  11833. x1 : h,
  11834. y1 : g,
  11835. x2 : h,
  11836. y2 : f
  11837. }, {
  11838. x1 : h,
  11839. y1 : f,
  11840. x2 : b,
  11841. y2 : f
  11842. }]
  11843. }
  11844. });
  11845. Ext.define("Gnt.view.Dependency", {
  11846. extend : "Ext.util.Observable",
  11847. requires : ["Gnt.feature.DependencyDragDrop", "Gnt.view.DependencyPainter"],
  11848. containerEl : null,
  11849. ganttView : null,
  11850. painter : null,
  11851. taskStore : null,
  11852. store : null,
  11853. dnd : null,
  11854. lineTpl : null,
  11855. enableDependencyDragDrop : true,
  11856. renderAllDepsBuffered : false,
  11857. dependencyCls : "sch-dependency",
  11858. selectedCls : "sch-dependency-selected",
  11859. dependencyPainterClass : "Gnt.view.DependencyPainter",
  11860. constructor : function(a) {
  11861. this.callParent(arguments);
  11862. var b = this.ganttView;
  11863. b.on({
  11864. refresh : this.renderAllDependenciesBuffered,
  11865. scope : this
  11866. });
  11867. this.bindTaskStore(b.getTaskStore());
  11868. this.bindDependencyStore(a.store);
  11869. if (!this.lineTpl) {
  11870. this.lineTpl = Ext
  11871. .create(
  11872. "Ext.XTemplate",
  11873. '<tpl for=".">'
  11874. + Ext.String
  11875. .format(
  11876. '<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)'
  11877. + (!Ext.isGecko
  11878. && Ext.isBorderBox
  11879. ? "+2"
  11880. : "")
  11881. + "]}px;height:{[Math.abs(values.y1-values.y2)"
  11882. + (!Ext.isGecko
  11883. && Ext.isBorderBox
  11884. ? "+2"
  11885. : "")
  11886. + ']}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="'
  11887. + Ext.BLANK_IMAGE_URL
  11888. + '" class="{0}-arrow {0}-arrow-{[this.getArrowDirection(values.lineCoordinates)]} {[this.getSuffixedCls(values.cls, "-arrow")]}" /></div>',
  11889. this.dependencyCls)
  11890. + "</tpl>", {
  11891. compiled : true,
  11892. disableFormats : true,
  11893. getArrowDirection : function(d) {
  11894. var c = d[d.length - 1];
  11895. if (c.y2 < c.y1) {
  11896. return "up"
  11897. }
  11898. if (c.x1 === c.x2) {
  11899. return "down"
  11900. } else {
  11901. if (c.x1 > c.x2) {
  11902. return "left"
  11903. } else {
  11904. return "right"
  11905. }
  11906. }
  11907. },
  11908. getSuffixedCls : function(c, d) {
  11909. if (c && c.indexOf(" ") != -1) {
  11910. return c.replace(/^\s*(.*)\s*$/, "$1")
  11911. .split(/\s+/).join(d + " ")
  11912. + d
  11913. } else {
  11914. return c + d
  11915. }
  11916. }
  11917. })
  11918. }
  11919. this.painter = Ext.create(this.dependencyPainterClass, Ext.apply({
  11920. rowHeight : b.rowHeight,
  11921. taskStore : this.taskStore,
  11922. view : b
  11923. }, a));
  11924. this.addEvents("beforednd", "dndstart", "drop", "afterdnd",
  11925. "beforecascade", "cascade", "dependencydblclick", "refresh");
  11926. if (this.enableDependencyDragDrop) {
  11927. this.dnd = Ext.create("Gnt.feature.DependencyDragDrop", {
  11928. ganttView : this.ganttView
  11929. });
  11930. this.dnd.on("drop", this.onDependencyDrop, this);
  11931. this.relayEvents(this.dnd, ["beforednd", "dndstart", "afterdnd",
  11932. "drop"])
  11933. }
  11934. this.containerEl = this.containerEl.createChild({
  11935. cls : "sch-dependencyview-ct"
  11936. });
  11937. this.ganttView.mon(this.containerEl, "dblclick",
  11938. this.onDependencyDblClick, this, {
  11939. delegate : "." + this.dependencyCls
  11940. });
  11941. if (b.rendered) {
  11942. this.renderAllDependenciesBuffered()
  11943. }
  11944. },
  11945. bindDependencyStore : function(a) {
  11946. this.depStoreListeners = {
  11947. refresh : this.renderAllDependenciesBuffered,
  11948. load : this.renderAllDependenciesBuffered,
  11949. add : this.onDependencyAdd,
  11950. update : this.onDependencyUpdate,
  11951. remove : this.onDependencyDelete,
  11952. scope : this
  11953. };
  11954. a.on(this.depStoreListeners);
  11955. this.store = a
  11956. },
  11957. unBindDependencyStore : function() {
  11958. if (this.depStoreListeners) {
  11959. this.store.un(this.depStoreListeners)
  11960. }
  11961. },
  11962. bindTaskStore : function(a) {
  11963. var b = this.ganttView;
  11964. this.taskStoreListeners = {
  11965. cascade : this.onTaskStoreCascade,
  11966. "root-fill-start" : this.onRootFillStart,
  11967. remove : this.renderAllDependenciesBuffered,
  11968. insert : this.renderAllDependenciesBuffered,
  11969. append : this.renderAllDependenciesBuffered,
  11970. move : this.renderAllDependenciesBuffered,
  11971. update : this.onTaskUpdated,
  11972. scope : this
  11973. };
  11974. if (b.animate) {
  11975. this.ganttViewListeners = {
  11976. afterexpand : this.renderAllDependenciesBuffered,
  11977. aftercollapse : this.renderAllDependenciesBuffered,
  11978. scope : this
  11979. };
  11980. b.on(this.ganttViewListeners)
  11981. } else {
  11982. Ext.apply(this.taskStoreListeners, {
  11983. expand : this.renderAllDependenciesBuffered,
  11984. collapse : this.renderAllDependenciesBuffered
  11985. })
  11986. }
  11987. a.on(this.taskStoreListeners);
  11988. this.taskStore = a
  11989. },
  11990. onTaskStoreCascade : function(a, b) {
  11991. if (b && b.nbrAffected > 0) {
  11992. this.renderAllDependenciesBuffered()
  11993. }
  11994. },
  11995. unBindTaskStore : function(a) {
  11996. a = a || this.taskStore;
  11997. if (!a) {
  11998. return
  11999. }
  12000. if (this.ganttViewListeners) {
  12001. this.ganttView.un(this.ganttViewListeners)
  12002. }
  12003. a.un(this.taskStoreListeners)
  12004. },
  12005. onRootFillStart : function() {
  12006. var a = this.taskStore;
  12007. this.unBindTaskStore(a);
  12008. this.taskStore.on("root-fill-end", function() {
  12009. this.bindTaskStore(a)
  12010. }, this, {
  12011. single : true
  12012. })
  12013. },
  12014. onDependencyDblClick : function(b, a) {
  12015. var c = this.getRecordForDependencyEl(a);
  12016. this.fireEvent("dependencydblclick", this, c, b, a)
  12017. },
  12018. highlightDependency : function(a) {
  12019. if (!(a instanceof Ext.data.Model)) {
  12020. a = this.getDependencyRecordByInternalId(a)
  12021. }
  12022. this.getElementsForDependency(a).addCls(this.selectedCls)
  12023. },
  12024. unhighlightDependency : function(a) {
  12025. if (!(a instanceof Ext.data.Model)) {
  12026. a = this.getDependencyRecordByInternalId(a)
  12027. }
  12028. this.getElementsForDependency(a).removeCls(this.selectedCls)
  12029. },
  12030. getElementsForDependency : function(a) {
  12031. var b = a instanceof Ext.data.Model ? a.internalId : a;
  12032. return this.containerEl.select(".sch-dep-" + b)
  12033. },
  12034. depRe : new RegExp("sch-dep-([^\\s]+)"),
  12035. getDependencyRecordByInternalId : function(d) {
  12036. var c, b, a;
  12037. for (b = 0, a = this.store.getCount(); b < a; b++) {
  12038. c = this.store.getAt(b);
  12039. if (c.internalId == d) {
  12040. return c
  12041. }
  12042. }
  12043. return null
  12044. },
  12045. getRecordForDependencyEl : function(c) {
  12046. var a = c.className.match(this.depRe), d = null;
  12047. if (a && a[1]) {
  12048. var b = a[1];
  12049. d = this.getDependencyRecordByInternalId(b)
  12050. }
  12051. return d
  12052. },
  12053. renderAllDependenciesBuffered : function() {
  12054. var a = this;
  12055. this.containerEl.update("");
  12056. setTimeout(function() {
  12057. if (!a.ganttView.isDestroyed) {
  12058. a.renderAllDependencies()
  12059. }
  12060. }, 0)
  12061. },
  12062. renderAllDependencies : function() {
  12063. if (!this.containerEl.dom) {
  12064. return
  12065. }
  12066. this.getDependencyElements().remove();
  12067. this.renderDependencies(this.store.data.items);
  12068. this.fireEvent("refresh", this)
  12069. },
  12070. getDependencyElements : function() {
  12071. return this.containerEl.select("." + this.dependencyCls)
  12072. },
  12073. renderDependencies : function(b) {
  12074. if (b) {
  12075. var a = this.painter.getDependencyTplData(b);
  12076. this.lineTpl[Ext.isIE ? "insertFirst" : "append"](this.containerEl,
  12077. a)
  12078. }
  12079. },
  12080. renderTaskDependencies : function(d) {
  12081. var c = [];
  12082. if (!Ext.isArray(d)) {
  12083. d = [d]
  12084. }
  12085. for (var a = 0, b = d.length; a < b; a++) {
  12086. c = c.concat(d[a].getAllDependencies())
  12087. }
  12088. this.renderDependencies(c)
  12089. },
  12090. onDependencyUpdate : function(b, a) {
  12091. this.removeDependencyElements(a, false);
  12092. this.renderDependencies(a)
  12093. },
  12094. onDependencyAdd : function(a, b) {
  12095. this.renderDependencies(b)
  12096. },
  12097. removeDependencyElements : function(a, b) {
  12098. if (b !== false) {
  12099. this.getElementsForDependency(a).fadeOut({
  12100. remove : true
  12101. })
  12102. } else {
  12103. this.getElementsForDependency(a).remove()
  12104. }
  12105. },
  12106. onDependencyDelete : function(b, a) {
  12107. this.removeDependencyElements(a)
  12108. },
  12109. dimEventDependencies : function(a) {
  12110. this.containerEl.select(this.depRe + a).setOpacity(0.2)
  12111. },
  12112. clearSelectedDependencies : function() {
  12113. this.containerEl.select("." + this.selectedCls)
  12114. .removeCls(this.selectedCls)
  12115. },
  12116. onTaskUpdated : function(c, b, a) {
  12117. if (!this.taskStore.cascading
  12118. && a != Ext.data.Model.COMMIT
  12119. && (!b.previous || b.startDateField in b.previous || b.endDateField in b.previous)) {
  12120. this.updateDependencies(b)
  12121. }
  12122. },
  12123. updateDependencies : function(b) {
  12124. if (!Ext.isArray(b)) {
  12125. b = [b]
  12126. }
  12127. var a = this;
  12128. Ext.each(b, function(c) {
  12129. Ext.each(c.getAllDependencies(), function(d) {
  12130. a.removeDependencyElements(d, false)
  12131. })
  12132. });
  12133. this.renderTaskDependencies(b)
  12134. },
  12135. onNewDependencyCreated : function() {
  12136. },
  12137. onDependencyDrop : function(f, d, b, e) {
  12138. var c = this.store;
  12139. var a = new c.model({
  12140. fromTask : d,
  12141. toTask : b,
  12142. type : e
  12143. });
  12144. if (c.isValidDependency(a) && this.onNewDependencyCreated(a) !== false) {
  12145. c.add(a)
  12146. }
  12147. },
  12148. destroy : function() {
  12149. if (this.dnd) {
  12150. this.dnd.destroy()
  12151. }
  12152. this.unBindTaskStore();
  12153. this.unBindDependencyStore()
  12154. }
  12155. });
  12156. Ext.define("Gnt.view.Gantt", {
  12157. extend : "Sch.view.TimelineTreeView",
  12158. alias : ["widget.ganttview"],
  12159. requires : ["Gnt.view.Dependency", "Gnt.model.Task", "Gnt.template.Task",
  12160. "Gnt.template.ParentTask", "Gnt.template.Milestone",
  12161. "Gnt.feature.TaskDragDrop", "Gnt.feature.ProgressBarResize",
  12162. "Gnt.feature.TaskResize", "Sch.view.Horizontal"],
  12163. uses : ["Gnt.feature.LabelEditor", "Gnt.feature.DragCreator"],
  12164. _cmpCls : "sch-ganttview",
  12165. rowHeight : 22,
  12166. barMargin : 4,
  12167. scheduledEventName : "task",
  12168. trackOver : false,
  12169. toggleOnDblClick : false,
  12170. milestoneOffset : 8,
  12171. parentTaskOffset : 6,
  12172. eventSelector : ".sch-gantt-item",
  12173. eventWrapSelector : ".sch-event-wrap",
  12174. progressBarResizer : null,
  12175. taskResizer : null,
  12176. taskDragDrop : null,
  12177. dragCreator : null,
  12178. dependencyView : null,
  12179. resizeConfig : null,
  12180. createConfig : null,
  12181. dragDropConfig : null,
  12182. progressBarResizeConfig : null,
  12183. dependencyViewConfig : null,
  12184. constructor : function(a) {
  12185. var b = a.panel._top;
  12186. Ext.apply(this, {
  12187. taskStore : b.taskStore,
  12188. dependencyStore : b.dependencyStore,
  12189. enableDependencyDragDrop : b.enableDependencyDragDrop,
  12190. enableTaskDragDrop : b.enableTaskDragDrop,
  12191. enableProgressBarResize : b.enableProgressBarResize,
  12192. enableDragCreation : b.enableDragCreation,
  12193. allowParentTaskMove : b.allowParentTaskMove,
  12194. toggleParentTasksOnClick : b.toggleParentTasksOnClick,
  12195. resizeHandles : b.resizeHandles,
  12196. enableBaseline : b.baselineVisible || b.enableBaseline,
  12197. leftLabelField : b.leftLabelField,
  12198. rightLabelField : b.rightLabelField,
  12199. eventTemplate : b.eventTemplate,
  12200. parentEventTemplate : b.parentEventTemplate,
  12201. milestoneTemplate : b.milestoneTemplate,
  12202. resizeConfig : b.resizeConfig,
  12203. createConfig : b.createConfig,
  12204. dragDropConfig : b.dragDropConfig,
  12205. progressBarResizeConfig : b.progressBarResizeConfig
  12206. });
  12207. this.addEvents("taskclick", "taskdblclick", "taskcontextmenu",
  12208. "beforetaskresize", "taskresizestart", "partialtaskresize",
  12209. "aftertaskresize", "beforeprogressbarresize",
  12210. "progressbarresizestart", "afterprogressbarresize",
  12211. "beforetaskdrag", "taskdragstart", "taskdrop", "aftertaskdrop",
  12212. "labeledit_beforestartedit", "labeledit_beforecomplete",
  12213. "labeledit_complete", "beforedependencydrag",
  12214. "dependencydragstart", "dependencydrop",
  12215. "afterdependencydragdrop", "beforedragcreate",
  12216. "dragcreatestart", "dragcreateend", "afterdragcreate");
  12217. this.callParent(arguments)
  12218. },
  12219. initComponent : function() {
  12220. this.configureLabels();
  12221. this.setupGanttEvents();
  12222. this.callParent(arguments);
  12223. this.setupTemplates()
  12224. },
  12225. getDependencyStore : function() {
  12226. return this.dependencyStore
  12227. },
  12228. configureFeatures : function() {
  12229. if (this.enableProgressBarResize !== false) {
  12230. this.progressBarResizer = Ext.create(
  12231. "Gnt.feature.ProgressBarResize", Ext.apply({
  12232. gantt : this
  12233. }, this.progressBarResizeConfig || {}));
  12234. this.on({
  12235. beforeprogressbarresize : this.onBeforeTaskProgressBarResize,
  12236. progressbarresizestart : this.onTaskProgressBarResizeStart,
  12237. afterprogressbarresize : this.onTaskProgressBarResizeEnd,
  12238. scope : this
  12239. })
  12240. }
  12241. if (this.resizeHandles !== "none") {
  12242. this.taskResizer = Ext.create("Gnt.feature.TaskResize", Ext.apply({
  12243. gantt : this,
  12244. validatorFn : this.resizeValidatorFn
  12245. || Ext.emptyFn,
  12246. validatorFnScope : this.validatorFnScope
  12247. || this
  12248. }, this.resizeConfig || {}));
  12249. this.on({
  12250. beforedragcreate : this.onBeforeDragCreate,
  12251. beforetaskresize : this.onBeforeTaskResize,
  12252. taskresizestart : this.onTaskResizeStart,
  12253. aftertaskresize : this.onTaskResizeEnd,
  12254. scope : this
  12255. })
  12256. }
  12257. if (this.enableTaskDragDrop) {
  12258. this.taskDragDrop = Ext.create("Gnt.feature.TaskDragDrop", Ext
  12259. .apply({
  12260. gantt : this,
  12261. validatorFn : this.dndValidatorFn
  12262. || Ext.emptyFn,
  12263. validatorFnScope : this.validatorFnScope
  12264. || this
  12265. }, this.dragDropConfig));
  12266. this.on({
  12267. beforetaskdrag : this.onBeforeTaskDrag,
  12268. taskdragstart : this.onDragDropStart,
  12269. aftertaskdrop : this.onDragDropEnd,
  12270. scope : this
  12271. })
  12272. }
  12273. if (this.enableDragCreation) {
  12274. this.dragCreator = Ext.create("Gnt.feature.DragCreator", Ext.apply(
  12275. {
  12276. ganttView : this,
  12277. validatorFn : this.createValidatorFn
  12278. || Ext.emptyFn,
  12279. validatorFnScope : this.validatorFnScope
  12280. || this
  12281. }, this.createConfig))
  12282. }
  12283. },
  12284. prepareData : function(d, a, b) {
  12285. var c = this, e = {}, f = c.gridDataColumns || c.getGridColumns();
  12286. e[f[0].id] = this.renderTask(b);
  12287. return e
  12288. },
  12289. renderTask : function(k) {
  12290. var l = k.getStartDate(), n = this.timeAxis, s = Sch.util.Date, b = {}, A = "", h = n
  12291. .getStart(), g = n.getEnd(), C = k.isMilestone(), x = k
  12292. .isLeaf(), o, q, u;
  12293. if (l) {
  12294. var v = k.getEndDate()
  12295. || Sch.util.Date.add(l, Sch.util.Date.DAY, 1), e = Sch.util.Date
  12296. .intersectSpans(l, v, h, g);
  12297. if (e) {
  12298. u = v > g;
  12299. q = s.betweenLesser(l, h, g);
  12300. var z = Math.floor(this.getXYFromDate(q ? l : h)[0]), d = Math
  12301. .floor(this.getXYFromDate(u ? g : v)[0]), f = C ? 0 : d
  12302. - z;
  12303. if (!C && !x) {
  12304. if (u) {
  12305. f += this.parentTaskOffset
  12306. } else {
  12307. f += 2 * this.parentTaskOffset
  12308. }
  12309. }
  12310. b = {
  12311. id : k.internalId,
  12312. leftOffset : C ? (d || z) : z,
  12313. width : Math.max(1, f),
  12314. percentDone : Math.min(k.getPercentDone() || 0, 100)
  12315. };
  12316. o = this.eventRenderer.call(this.eventRendererScope || this, k,
  12317. b, k.store)
  12318. || {};
  12319. var t = this.leftLabelField, j = this.rightLabelField, B;
  12320. if (t) {
  12321. b.leftLabel = t.renderer.call(t.scope || this,
  12322. k.data[t.dataIndex], k)
  12323. }
  12324. if (j) {
  12325. b.rightLabel = j.renderer.call(j.scope || this,
  12326. k.data[j.dataIndex], k)
  12327. }
  12328. Ext.apply(b, o);
  12329. if (C) {
  12330. B = this.milestoneTemplate
  12331. } else {
  12332. b.width = Math.max(1, f);
  12333. var p = "";
  12334. if (u) {
  12335. p = " sch-event-endsoutside "
  12336. }
  12337. if (!q) {
  12338. p = " sch-event-startsoutside "
  12339. }
  12340. b.ctcls = (b.ctcls || "") + p;
  12341. B = this[x ? "eventTemplate" : "parentEventTemplate"]
  12342. }
  12343. var i = " sch-event-resizable-" + k.getResizable();
  12344. if (k.dirty) {
  12345. i += " sch-dirty "
  12346. }
  12347. if (k.isDraggable() === false) {
  12348. i += " sch-event-fixed "
  12349. }
  12350. b.cls = (b.cls || "") + (k.getCls() || "") + i;
  12351. A += B.apply(b)
  12352. }
  12353. }
  12354. if (this.enableBaseline) {
  12355. var r = k.getBaselineStartDate(), a = k.getBaselineEndDate();
  12356. if (!o) {
  12357. o = this.eventRenderer.call(this, k, b, k.store) || {}
  12358. }
  12359. if (r && a) {
  12360. u = a > g;
  12361. q = s.betweenLesser(r, h, g);
  12362. var c = k.isBaselineMilestone(), w = c
  12363. ? this.baselineMilestoneTemplate
  12364. : (k.isLeaf()
  12365. ? this.baselineTaskTemplate
  12366. : this.baselineParentTaskTemplate), m = Math
  12367. .floor(this.getXYFromDate(q ? r : h)[0]), y = c
  12368. ? 0
  12369. : Math.floor(this.getXYFromDate(u ? g : a)[0]) - m;
  12370. A += w.apply({
  12371. basecls : o.basecls || "",
  12372. id : k.internalId + "-base",
  12373. percentDone : k.getBaselinePercentDone(),
  12374. leftOffset : m,
  12375. width : Math.max(1, y)
  12376. })
  12377. }
  12378. }
  12379. return A
  12380. },
  12381. setupTemplates : function() {
  12382. var a = {
  12383. leftLabel : !!this.leftLabelField,
  12384. rightLabel : !!this.rightLabelField,
  12385. prefix : this.eventPrefix,
  12386. enableDependencyDragDrop : this.enableDependencyDragDrop !== false,
  12387. resizeHandles : this.resizeHandles,
  12388. enableProgressBarResize : this.enableProgressBarResize
  12389. };
  12390. if (!this.eventTemplate) {
  12391. a.baseCls = "sch-gantt-task {ctcls}";
  12392. this.eventTemplate = Ext.create("Gnt.template.Task", a)
  12393. }
  12394. if (!this.parentEventTemplate) {
  12395. a.baseCls = "sch-gantt-parent-task {ctcls}";
  12396. this.parentEventTemplate = Ext.create("Gnt.template.ParentTask", a)
  12397. }
  12398. if (!this.milestoneTemplate) {
  12399. a.baseCls = "sch-gantt-milestone {ctcls}";
  12400. this.milestoneTemplate = Ext.create("Gnt.template.Milestone", a)
  12401. }
  12402. if (this.enableBaseline) {
  12403. a = {
  12404. prefix : this.eventPrefix
  12405. };
  12406. if (!this.baselineTaskTemplate) {
  12407. a.baseCls = "sch-gantt-task-baseline sch-gantt-baseline-item {basecls}";
  12408. this.baselineTaskTemplate = Ext.create("Gnt.template.Task", a)
  12409. }
  12410. if (!this.baselineParentTaskTemplate) {
  12411. a.baseCls = "sch-gantt-parenttask-baseline sch-gantt-baseline-item {basecls}";
  12412. this.baselineParentTaskTemplate = Ext.create(
  12413. "Gnt.template.ParentTask", a)
  12414. }
  12415. if (!this.baselineMilestoneTemplate) {
  12416. a.baseCls = "sch-gantt-milestone-baseline sch-gantt-baseline-item {basecls}";
  12417. this.baselineMilestoneTemplate = Ext.create(
  12418. "Gnt.template.Milestone", a)
  12419. }
  12420. }
  12421. },
  12422. getDependencyView : function() {
  12423. return this.dependencyView
  12424. },
  12425. getTaskStore : function() {
  12426. return this.taskStore
  12427. },
  12428. initDependencies : function() {
  12429. if (this.dependencyStore) {
  12430. var b = this, a = Ext.create("Gnt.view.Dependency", Ext.apply({
  12431. containerEl : b.el,
  12432. ganttView : b,
  12433. enableDependencyDragDrop : b.enableDependencyDragDrop,
  12434. store : b.dependencyStore
  12435. }, this.dependencyViewConfig));
  12436. a.on({
  12437. beforednd : b.onBeforeDependencyDrag,
  12438. dndstart : b.onDependencyDragStart,
  12439. drop : b.onDependencyDrop,
  12440. afterdnd : b.onAfterDependencyDragDrop,
  12441. beforecascade : b.onBeforeCascade,
  12442. cascade : b.onCascade,
  12443. scope : b
  12444. });
  12445. b.dependencyView = a;
  12446. b.relayEvents(a, ["dependencydblclick"])
  12447. }
  12448. },
  12449. setupGanttEvents : function() {
  12450. var a = this.getSelectionModel();
  12451. if (this.toggleParentTasksOnClick) {
  12452. this.on({
  12453. taskclick : function(c, b) {
  12454. if (!b.isLeaf()) {
  12455. this.toggle(b)
  12456. }
  12457. },
  12458. scope : this
  12459. })
  12460. }
  12461. },
  12462. configureLabels : function() {
  12463. var c = {
  12464. renderer : function(d) {
  12465. return d
  12466. },
  12467. dataIndex : undefined
  12468. };
  12469. var b = this.leftLabelField;
  12470. if (b) {
  12471. if (Ext.isString(b)) {
  12472. b = this.leftLabelField = {
  12473. dataIndex : b
  12474. }
  12475. }
  12476. Ext.applyIf(b, c);
  12477. if (b.editor) {
  12478. b.editor = Ext.create("Gnt.feature.LabelEditor", this, {
  12479. alignment : "r-r",
  12480. delegate : ".sch-gantt-label-left",
  12481. labelPosition : "left",
  12482. field : b.editor,
  12483. dataIndex : b.dataIndex
  12484. })
  12485. }
  12486. }
  12487. var a = this.rightLabelField;
  12488. if (a) {
  12489. if (Ext.isString(a)) {
  12490. a = this.rightLabelField = {
  12491. dataIndex : a
  12492. }
  12493. }
  12494. Ext.applyIf(a, c);
  12495. if (a.editor) {
  12496. a.editor = Ext.create("Gnt.feature.LabelEditor", this, {
  12497. alignment : "l-l",
  12498. delegate : ".sch-gantt-label-right",
  12499. labelPosition : "right",
  12500. field : a.editor,
  12501. dataIndex : a.dataIndex
  12502. })
  12503. }
  12504. }
  12505. this.on("labeledit_beforestartedit", this.onBeforeLabelEdit, this)
  12506. },
  12507. onBeforeTaskDrag : function(b, a) {
  12508. return !this.readOnly && a.isDraggable() !== false
  12509. && (this.allowParentTaskMove || a.isLeaf())
  12510. },
  12511. onDragDropStart : function() {
  12512. if (this.tip) {
  12513. this.tip.disable()
  12514. }
  12515. },
  12516. onDragDropEnd : function() {
  12517. if (this.tip) {
  12518. this.tip.enable()
  12519. }
  12520. },
  12521. onTaskProgressBarResizeStart : function() {
  12522. if (this.tip) {
  12523. this.tip.hide();
  12524. this.tip.disable()
  12525. }
  12526. },
  12527. onTaskProgressBarResizeEnd : function() {
  12528. if (this.tip) {
  12529. this.tip.enable()
  12530. }
  12531. },
  12532. onTaskResizeStart : function() {
  12533. if (this.tip) {
  12534. this.tip.hide();
  12535. this.tip.disable()
  12536. }
  12537. },
  12538. onTaskResizeEnd : function() {
  12539. if (this.tip) {
  12540. this.tip.enable()
  12541. }
  12542. },
  12543. onBeforeDragCreate : function() {
  12544. return !this.readOnly
  12545. },
  12546. onBeforeTaskResize : function(a, b) {
  12547. return !this.readOnly && b.getSchedulingMode() !== "EffortDriven"
  12548. },
  12549. onBeforeTaskProgressBarResize : function() {
  12550. return !this.readOnly
  12551. },
  12552. onBeforeLabelEdit : function() {
  12553. return !this.readOnly
  12554. },
  12555. onBeforeEdit : function() {
  12556. return !this.readOnly
  12557. },
  12558. beforeRender : function() {
  12559. this.addCls("sch-ganttview");
  12560. this.callParent(arguments)
  12561. },
  12562. afterRender : function() {
  12563. this.initDependencies();
  12564. this.callParent(arguments);
  12565. this.el.on("mousemove", this.configureFeatures, this, {
  12566. single : true
  12567. })
  12568. },
  12569. resolveTaskRecord : function(a) {
  12570. var b = this.findItemByChild(a);
  12571. if (b) {
  12572. return this.getRecord(this.findItemByChild(a))
  12573. }
  12574. return null
  12575. },
  12576. resolveEventRecord : function(a) {
  12577. return this.resolveTaskRecord(a)
  12578. },
  12579. highlightTask : function(b, a) {
  12580. if (!(b instanceof Ext.data.Model)) {
  12581. b = this.taskStore.getById(b)
  12582. }
  12583. if (b) {
  12584. var d = this.getNode(b);
  12585. if (d) {
  12586. Ext.fly(d).addCls("sch-gantt-task-highlighted")
  12587. }
  12588. var c = b.getId() || b.internalId;
  12589. if (a !== false) {
  12590. this.dependencyStore.each(function(e) {
  12591. if (e.getSourceId() == c) {
  12592. this.highlightDependency(e.id);
  12593. this.highlightTask(e.getTargetId(), a)
  12594. }
  12595. }, this)
  12596. }
  12597. }
  12598. },
  12599. unhighlightTask : function(a, c) {
  12600. if (!(a instanceof Ext.data.Model)) {
  12601. a = this.taskStore.getById(a)
  12602. }
  12603. if (a) {
  12604. Ext.fly(this.getNode(a)).removeCls("sch-gantt-task-highlighted");
  12605. var b = a.getId() || a.internalId;
  12606. if (c !== false) {
  12607. this.dependencyStore.each(function(d) {
  12608. if (d.getSourceId() == b) {
  12609. this.unhighlightDependency(d.id);
  12610. this.unhighlightTask(d.getTargetId(), c)
  12611. }
  12612. }, this)
  12613. }
  12614. }
  12615. },
  12616. clearSelectedTasksAndDependencies : function() {
  12617. this.getSelectionModel().deselectAll();
  12618. this.getDependencyView().clearSelectedDependencies();
  12619. this.el.select("tr.sch-gantt-task-highlighted")
  12620. .removeCls("sch-gantt-task-highlighted")
  12621. },
  12622. getCriticalPaths : function() {
  12623. return this.taskStore.getCriticalPaths()
  12624. },
  12625. highlightCriticalPaths : function() {
  12626. this.clearSelectedTasksAndDependencies();
  12627. var g = this.getCriticalPaths(), c = this.getDependencyView(), f = this.dependencyStore, e, d, b, a;
  12628. Ext.each(g, function(h) {
  12629. for (d = 0, b = h.length; d < b; d++) {
  12630. e = h[d];
  12631. this.highlightTask(e, false);
  12632. if (d < (b - 1)) {
  12633. a = f.getAt(f.findBy(function(i) {
  12634. return i.getTargetId() === (e.getId() || e.internalId)
  12635. && i.getSourceId() === (h[d + 1]
  12636. .getId() || h[d + 1].internalId)
  12637. }));
  12638. c.highlightDependency(a)
  12639. }
  12640. }
  12641. }, this);
  12642. this.addCls("sch-gantt-critical-chain");
  12643. this.getSelectionModel().setLocked(true)
  12644. },
  12645. unhighlightCriticalPaths : function() {
  12646. this.el.removeCls("sch-gantt-critical-chain");
  12647. this.getSelectionModel().setLocked(false);
  12648. this.clearSelectedTasksAndDependencies()
  12649. },
  12650. getXOffset : function(a) {
  12651. var b = 0;
  12652. if (a.isMilestone()) {
  12653. b = this.milestoneOffset
  12654. } else {
  12655. if (!a.isLeaf()) {
  12656. b = this.parentTaskOffset
  12657. }
  12658. }
  12659. return b
  12660. },
  12661. onDestroy : function() {
  12662. if (this.dependencyView) {
  12663. this.dependencyView.destroy()
  12664. }
  12665. this.callParent(arguments)
  12666. },
  12667. highlightDependency : function(a) {
  12668. this.dependencyView.highlightDependency(a)
  12669. },
  12670. unhighlightDependency : function(a) {
  12671. this.dependencyView.unhighlightDependency(a)
  12672. },
  12673. onBeforeDependencyDrag : function(b, a) {
  12674. return this.fireEvent("beforedependencydrag", this, a)
  12675. },
  12676. onDependencyDragStart : function(a) {
  12677. this.fireEvent("dependencydragstart", this);
  12678. if (this.tip) {
  12679. this.tip.disable()
  12680. }
  12681. },
  12682. onDependencyDrop : function(b, c, a, d) {
  12683. this.fireEvent("dependencydrop", this, this.taskStore.getNodeById(c),
  12684. this.taskStore.getById(a), d)
  12685. },
  12686. onAfterDependencyDragDrop : function() {
  12687. this.fireEvent("afterdependencydragdrop", this);
  12688. if (this.tip) {
  12689. this.tip.enable()
  12690. }
  12691. },
  12692. onBeforeCascade : function(a, b) {
  12693. this.taskStore.un("update", this.onUpdate, this)
  12694. },
  12695. onCascade : function(a, b) {
  12696. this.taskStore.on("update", this.onUpdate, this)
  12697. },
  12698. onUpdate : function(c, a, b, d) {
  12699. if (d && d.length === 1 && d[0] === "expanded") {
  12700. return
  12701. }
  12702. this.callParent(arguments)
  12703. },
  12704. getLeftEditor : function() {
  12705. return this.leftLabelField.editor
  12706. },
  12707. getRightEditor : function() {
  12708. return this.rightLabelField.editor
  12709. },
  12710. editLeftLabel : function(a) {
  12711. var b = this.leftLabelField && this.getLeftEditor();
  12712. if (b) {
  12713. b.edit(a)
  12714. }
  12715. },
  12716. editRightLabel : function(a) {
  12717. var b = this.rightLabelField && this.getRightEditor();
  12718. if (b) {
  12719. b.edit(a)
  12720. }
  12721. },
  12722. getOuterElementFromEventRecord : function(a) {
  12723. var b = this.callParent([a]);
  12724. return b && b.up(this.eventWrapSelector) || null
  12725. },
  12726. getDependenciesForTask : function(a) {
  12727. console
  12728. .warn("`ganttPanel.getDependenciesForTask()` is deprecated, use `task.getAllDependencies()` instead");
  12729. return a.getAllDependencies()
  12730. },
  12731. setNewTemplate : function() {
  12732. var b = this, a = b.headerCt.getColumnsForTpl(true);
  12733. b.tpl = b.getTableChunker().getTableTpl({
  12734. columns : [a[0]],
  12735. features : b.features
  12736. })
  12737. },
  12738. onAdd : function() {
  12739. Ext.suspendLayouts();
  12740. this.callParent(arguments);
  12741. Ext.resumeLayouts()
  12742. },
  12743. onRemove : function() {
  12744. Ext.suspendLayouts();
  12745. this.callParent(arguments);
  12746. Ext.resumeLayouts()
  12747. }
  12748. });
  12749. Ext.define("Gnt.panel.Gantt", {
  12750. extend : "Sch.panel.TimelineTreePanel",
  12751. alias : ["widget.ganttpanel"],
  12752. alternateClassName : ["Sch.gantt.GanttPanel"],
  12753. requires : ["Gnt.view.Gantt", "Gnt.model.Dependency",
  12754. "Gnt.data.ResourceStore", "Gnt.data.AssignmentStore",
  12755. "Gnt.feature.WorkingTime", "Gnt.data.Calendar",
  12756. "Gnt.data.TaskStore", "Gnt.data.DependencyStore"],
  12757. uses : ["Sch.plugin.CurrentTimeLine"],
  12758. lockedXType : "treepanel",
  12759. normalXType : "ganttpanel",
  12760. viewType : "ganttview",
  12761. syncRowHeight : false,
  12762. layout : "border",
  12763. lightWeight : true,
  12764. leftLabelField : null,
  12765. rightLabelField : null,
  12766. highlightWeekends : true,
  12767. weekendsAreWorkdays : false,
  12768. skipWeekendsDuringDragDrop : true,
  12769. enableTaskDragDrop : true,
  12770. enableDependencyDragDrop : true,
  12771. enableProgressBarResize : false,
  12772. toggleParentTasksOnClick : true,
  12773. addRowOnTab : true,
  12774. recalculateParents : true,
  12775. cascadeChanges : false,
  12776. showTodayLine : false,
  12777. enableBaseline : false,
  12778. baselineVisible : false,
  12779. enableAnimations : false,
  12780. workingTimePlugin : null,
  12781. todayLinePlugin : null,
  12782. allowParentTaskMove : false,
  12783. enableDragCreation : true,
  12784. eventRenderer : Ext.emptyFn,
  12785. eventRendererScope : null,
  12786. eventTemplate : null,
  12787. parentEventTemplate : null,
  12788. milestoneTemplate : null,
  12789. autoHeight : null,
  12790. calendar : null,
  12791. taskStore : null,
  12792. dependencyStore : null,
  12793. resourceStore : null,
  12794. assignmentStore : null,
  12795. columnLines : true,
  12796. dndValidatorFn : Ext.emptyFn,
  12797. createValidatorFn : Ext.emptyFn,
  12798. resizeHandles : "both",
  12799. resizeValidatorFn : Ext.emptyFn,
  12800. resizeConfig : null,
  12801. progressBarResizeConfig : null,
  12802. dragDropConfig : null,
  12803. createConfig : null,
  12804. refreshLockedTreeOnDependencyUpdate : false,
  12805. initStores : function() {
  12806. var a = Ext.StoreMgr.lookup(this.taskStore || this.store);
  12807. if (!a) {
  12808. Ext.Error.raise("You must specify a taskStore config")
  12809. }
  12810. if (!(a instanceof Gnt.data.TaskStore)) {
  12811. Ext.Error
  12812. .raise("A `taskStore` should be an instance of `Gnt.data.TaskStore` (or of a subclass)")
  12813. }
  12814. Ext.apply(this, {
  12815. store : a,
  12816. taskStore : a
  12817. });
  12818. var d = this.calendar = a.calendar;
  12819. if (this.needToTranslateOption("weekendsAreWorkdays")) {
  12820. d.setWeekendsAreWorkDays(this.weekendsAreWorkdays)
  12821. }
  12822. if (a.dependencyStore) {
  12823. this.dependencyStore = a.dependencyStore
  12824. } else {
  12825. if (this.dependencyStore) {
  12826. this.dependencyStore = Ext.StoreMgr
  12827. .lookup(this.dependencyStore);
  12828. a.setDependencyStore(this.dependencyStore)
  12829. } else {
  12830. this.dependencyStore = Ext.create("Gnt.data.DependencyStore");
  12831. a.setDependencyStore(this.dependencyStore)
  12832. }
  12833. }
  12834. if (!(this.dependencyStore instanceof Gnt.data.DependencyStore)) {
  12835. Ext.Error
  12836. .raise("The Gantt dependency store should be a Gnt.data.DependencyStore, or a subclass thereof.")
  12837. }
  12838. var b;
  12839. if (a.getResourceStore()) {
  12840. b = a.getResourceStore()
  12841. } else {
  12842. if (this.resourceStore) {
  12843. b = Ext.StoreMgr.lookup(this.resourceStore)
  12844. } else {
  12845. b = Ext.create("Gnt.data.ResourceStore")
  12846. }
  12847. }
  12848. if (!(b instanceof Gnt.data.ResourceStore)) {
  12849. Ext.Error
  12850. .raise("A `ResourceStore` should be an instance of `Gnt.data.ResourceStore` (or of a subclass)")
  12851. }
  12852. var c;
  12853. if (a.getAssignmentStore()) {
  12854. c = a.getAssignmentStore()
  12855. } else {
  12856. if (this.assignmentStore) {
  12857. c = Ext.StoreMgr.lookup(this.assignmentStore)
  12858. } else {
  12859. c = Ext.create("Gnt.data.AssignmentStore")
  12860. }
  12861. }
  12862. if (!(c instanceof Gnt.data.AssignmentStore)) {
  12863. Ext.Error
  12864. .raise("An `assignmentStore` should be an instance of `Gnt.data.AssignmentStore` (or of a subclass)")
  12865. }
  12866. if (this.lockable) {
  12867. this.bindAssignmentStore(c, true);
  12868. this.bindResourceStore(b, true)
  12869. }
  12870. },
  12871. initComponent : function() {
  12872. if (Ext.isBoolean(this.showBaseline)) {
  12873. this.enableBaseline = this.baselineVisible = this.showBaseline;
  12874. this.showBaseline = Gnt.panel.Gantt.prototype.showBaseline
  12875. }
  12876. this.autoHeight = false;
  12877. this.initStores();
  12878. if (this.needToTranslateOption("cascadeChanges")) {
  12879. this.setCascadeChanges(this.cascadeChanges)
  12880. }
  12881. if (this.needToTranslateOption("recalculateParents")) {
  12882. this.setRecalculateParents(this.recalculateParents)
  12883. }
  12884. if (this.needToTranslateOption("skipWeekendsDuringDragDrop")) {
  12885. this.setSkipWeekendsDuringDragDrop(this.skipWeekendsDuringDragDrop)
  12886. }
  12887. if (this.lockable) {
  12888. this.lockedGridConfig = this.lockedGridConfig || {};
  12889. Ext.apply(this.lockedGridConfig, {
  12890. columnLines : true,
  12891. rowLines : true
  12892. });
  12893. this.configureFunctionality();
  12894. this.mon(this.taskStore, "beforecascade", function(e) {
  12895. var d = this.normalGrid.getView().store;
  12896. d.suspendEvents()
  12897. }, this);
  12898. this.mon(this.taskStore, "cascade", function(h, d) {
  12899. var g = this.normalGrid.getView().store;
  12900. g.resumeEvents();
  12901. if (d.nbrAffected > 0) {
  12902. var e = this.normalGrid.getView();
  12903. var f = this.lockedGrid.getView();
  12904. e.refreshKeepingScroll(true);
  12905. setTimeout(function() {
  12906. f.saveScrollState();
  12907. f.refresh();
  12908. f.restoreScrollState()
  12909. }, 0)
  12910. }
  12911. }, this);
  12912. this.mon(this.taskStore, "refresh", function() {
  12913. this.getSchedulingView().refreshKeepingScroll(true);
  12914. if (Ext.versions.extjs.isLessThan("4.1.2")) {
  12915. var e = this.getSchedulingView().selModel.selected, f = this, d;
  12916. e.each(function(g) {
  12917. d = f.getSchedulingView().store.indexOfId(g
  12918. .getId());
  12919. f.getSchedulingView().onRowSelect(d);
  12920. f.view.lockedView.onRowSelect(d)
  12921. })
  12922. }
  12923. }, this)
  12924. }
  12925. this.callParent(arguments);
  12926. var a = this.getSchedulingView();
  12927. this.relayEvents(a, ["taskclick", "taskdblclick", "taskcontextmenu",
  12928. "beforetaskresize", "taskresizestart",
  12929. "partialtaskresize", "aftertaskresize",
  12930. "beforeprogressbarresize", "progressbarresizestart",
  12931. "afterprogressbarresize", "beforetaskdrag",
  12932. "taskdragstart", "taskdrop", "aftertaskdrop",
  12933. "labeledit_beforestartedit",
  12934. "labeledit_beforecomplete", "labeledit_complete",
  12935. "beforedependencydrag", "dependencydragstart",
  12936. "dependencydrop", "afterdependencydragdrop",
  12937. "dependencydblclick", "beforedragcreate",
  12938. "dragcreatestart", "dragcreateend", "afterdragcreate"]);
  12939. if (this.lockable) {
  12940. this.bodyCls = (this.bodyCls || "")
  12941. + " sch-ganttpanel-container-body";
  12942. a.store.calendar = this.calendar;
  12943. this.fixSelectionModel();
  12944. if (this.addRowOnTab) {
  12945. var b = this.lockedGrid, c = this.getSelectionModel();
  12946. c.onEditorTab = Ext.Function.createInterceptor(c.onEditorTab,
  12947. function(h, i) {
  12948. var g = b.view, f = h.getActiveRecord(), j = h
  12949. .getActiveColumn(), d = g.getPosition(f, j);
  12950. if (!i.shiftKey
  12951. && d.column === b.headerCt.getColumnCount()
  12952. - 1
  12953. && d.row === b.view.store.getCount() - 1) {
  12954. f.addTaskBelow({
  12955. leaf : true
  12956. })
  12957. }
  12958. })
  12959. }
  12960. }
  12961. },
  12962. needToTranslateOption : function(a) {
  12963. return this.hasOwnProperty(a) || this.self.prototype.hasOwnProperty(a)
  12964. && this.self != Gnt.panel.Gantt
  12965. },
  12966. fixSelectionModel : function() {
  12967. var a = this.getSelectionModel();
  12968. var d = this.lockedGrid.getView();
  12969. var c = this.normalGrid.getView();
  12970. d.__lockedType = "locked";
  12971. c.__lockedType = "normal";
  12972. var e = d.onAdd;
  12973. d.onAdd = function() {
  12974. a.__preventUpdateOf = "normal";
  12975. e.apply(this, arguments);
  12976. delete a.__preventUpdateOf
  12977. };
  12978. var b = c.onAdd;
  12979. c.onAdd = function() {
  12980. a.__preventUpdateOf = "locked";
  12981. b.apply(this, arguments);
  12982. delete a.__preventUpdateOf
  12983. };
  12984. var f = d.store;
  12985. d.bindStore(null);
  12986. c.bindStore(null);
  12987. d.bindStore(f);
  12988. c.bindStore(f);
  12989. Ext.apply(a, {
  12990. onSelectChange : function(m, j, q, g) {
  12991. var o = this, r = o.views, k = r.length, p = o.store, h = p
  12992. .indexOf(m), n = j ? "select" : "deselect", l = 0;
  12993. if ((q || o.fireEvent("before" + n, o, m, h)) !== false
  12994. && g() !== false) {
  12995. for (; l < k; l++) {
  12996. if (!this.__preventUpdateOf
  12997. || r[l].__lockedType != this.__preventUpdateOf) {
  12998. if (j) {
  12999. r[l].onRowSelect(h, q)
  13000. } else {
  13001. r[l].onRowDeselect(h, q)
  13002. }
  13003. }
  13004. }
  13005. if (!q) {
  13006. o.fireEvent(n, o, m, h)
  13007. }
  13008. }
  13009. }
  13010. })
  13011. },
  13012. getDependencyView : function() {
  13013. return this.getSchedulingView().getDependencyView()
  13014. },
  13015. disableWeekendHighlighting : function(a) {
  13016. this.workingTimePlugin.setDisabled(a)
  13017. },
  13018. resolveTaskRecord : function(a) {
  13019. return this.getSchedulingView().resolveTaskRecord(a)
  13020. },
  13021. fitTimeColumns : function() {
  13022. this.getSchedulingView().fitColumns()
  13023. },
  13024. getResourceStore : function() {
  13025. return this.getTaskStore().getResourceStore()
  13026. },
  13027. getAssignmentStore : function() {
  13028. return this.getTaskStore().getAssignmentStore()
  13029. },
  13030. getTaskStore : function() {
  13031. return this.taskStore
  13032. },
  13033. getDependencyStore : function() {
  13034. return this.dependencyStore
  13035. },
  13036. onDragDropStart : function() {
  13037. if (this.tip) {
  13038. this.tip.hide();
  13039. this.tip.disable()
  13040. }
  13041. },
  13042. onDragDropEnd : function() {
  13043. if (this.tip) {
  13044. this.tip.enable()
  13045. }
  13046. },
  13047. configureFunctionality : function() {
  13048. var a = this.plugins = [].concat(this.plugins || []);
  13049. if (this.highlightWeekends) {
  13050. this.workingTimePlugin = Ext.create("Gnt.feature.WorkingTime", {
  13051. calendar : this.calendar
  13052. });
  13053. a.push(this.workingTimePlugin)
  13054. }
  13055. if (this.showTodayLine) {
  13056. this.todayLinePlugin = new Sch.plugin.CurrentTimeLine();
  13057. a.push(this.todayLinePlugin)
  13058. }
  13059. },
  13060. getWorkingTimePlugin : function() {
  13061. return this.workingTimePlugin
  13062. },
  13063. beforeRender : function() {
  13064. if (this.lockable) {
  13065. var a = " sch-ganttpanel sch-horizontal ";
  13066. if (this.highlightWeekends) {
  13067. a += " sch-ganttpanel-highlightweekends "
  13068. }
  13069. this.addCls(a);
  13070. if (this.baselineVisible) {
  13071. this.showBaseline()
  13072. }
  13073. }
  13074. this.callParent(arguments)
  13075. },
  13076. updateDependencyTasks : function(b) {
  13077. var a = b.getSourceTask(this.taskStore);
  13078. var c = b.getTargetTask(this.taskStore);
  13079. var d = this.lockedGrid.getView();
  13080. if (a) {
  13081. d.onUpdate(d.store, a)
  13082. }
  13083. if (c) {
  13084. d.onUpdate(d.store, c)
  13085. }
  13086. },
  13087. registerLockedDependencyListeners : function() {
  13088. var c = this;
  13089. var a = this.getDependencyStore();
  13090. var b = {
  13091. load : function() {
  13092. c.lockedGrid.getView().refresh()
  13093. },
  13094. add : function(e, d) {
  13095. for (var f = 0; f < d.length; f++) {
  13096. c.updateDependencyTasks(d[f])
  13097. }
  13098. },
  13099. update : function(e, d) {
  13100. c.updateDependencyTasks(d)
  13101. },
  13102. remove : function(e, d) {
  13103. c.updateDependencyTasks(d)
  13104. }
  13105. };
  13106. a.un(b);
  13107. a.on(b)
  13108. },
  13109. afterRender : function() {
  13110. this.callParent(arguments);
  13111. if (this.lockable) {
  13112. this.applyPatches()
  13113. }
  13114. },
  13115. showBaseline : function() {
  13116. this.addCls("sch-ganttpanel-showbaseline")
  13117. },
  13118. hideBaseline : function() {
  13119. this.removeCls("sch-ganttpanel-showbaseline")
  13120. },
  13121. toggleBaseline : function() {
  13122. this.toggleCls("sch-ganttpanel-showbaseline")
  13123. },
  13124. zoomToFit : function() {
  13125. var a = this.taskStore.getTotalTimeSpan();
  13126. if (a.start && a.end && a.start < a.end) {
  13127. this.setTimeSpan(a.start, a.end);
  13128. this.fitTimeColumns()
  13129. }
  13130. },
  13131. getCascadeChanges : function() {
  13132. return this.taskStore.cascadeChanges
  13133. },
  13134. setCascadeChanges : function(a) {
  13135. this.taskStore.cascadeChanges = a
  13136. },
  13137. getRecalculateParents : function() {
  13138. return this.taskStore.recalculateParents
  13139. },
  13140. setRecalculateParents : function(a) {
  13141. this.taskStore.recalculateParents = a
  13142. },
  13143. setSkipWeekendsDuringDragDrop : function(a) {
  13144. this.taskStore.skipWeekendsDuringDragDrop = this.skipWeekendsDuringDragDrop = a
  13145. },
  13146. getSkipWeekendsDuringDragDrop : function() {
  13147. return this.taskStore.skipWeekendsDuringDragDrop
  13148. },
  13149. applyPatches : function() {
  13150. if (Ext.tree.plugin && Ext.tree.plugin.TreeViewDragDrop) {
  13151. var a;
  13152. Ext.each(this.lockedGrid.getView().plugins, function(b) {
  13153. if (b instanceof Ext.tree.plugin.TreeViewDragDrop) {
  13154. a = b;
  13155. return false
  13156. }
  13157. });
  13158. if (!a || !a.dropZone) {
  13159. return
  13160. }
  13161. a.dropZone.handleNodeDrop = function(e, l, f) {
  13162. var n = this, o = n.view, g = l.parentNode, p = o.getStore(), r = [], b, d, k, c, j, m, q, h;
  13163. if (e.copy) {
  13164. b = e.records;
  13165. e.records = [];
  13166. for (d = 0, k = b.length; d < k; d++) {
  13167. e.records.push(Ext.apply({}, b[d].data))
  13168. }
  13169. }
  13170. n.cancelExpand();
  13171. if (f == "before") {
  13172. c = g.insertBefore;
  13173. j = [null, l];
  13174. l = g
  13175. } else {
  13176. if (f == "after") {
  13177. if (l.nextSibling) {
  13178. c = g.insertBefore;
  13179. j = [null, l.nextSibling]
  13180. } else {
  13181. c = g.appendChild;
  13182. j = [null]
  13183. }
  13184. l = g
  13185. } else {
  13186. if (!l.isExpanded()) {
  13187. m = true
  13188. }
  13189. c = l.appendChild;
  13190. j = [null]
  13191. }
  13192. }
  13193. q = function() {
  13194. var i;
  13195. for (d = 0, k = e.records.length; d < k; d++) {
  13196. j[0] = e.records[d];
  13197. j[0].isMove = true;
  13198. i = c.apply(l, j);
  13199. delete j[0].isMove;
  13200. if (Ext.enableFx && n.dropHighlight) {
  13201. r.push(o.getNode(i))
  13202. }
  13203. }
  13204. if (Ext.enableFx && n.dropHighlight) {
  13205. Ext.Array.forEach(r, function(s) {
  13206. if (s) {
  13207. Ext
  13208. .fly(s.firstChild
  13209. ? s.firstChild
  13210. : s)
  13211. .highlight(n.dropHighlightColor)
  13212. }
  13213. })
  13214. }
  13215. };
  13216. if (m) {
  13217. l.expand(false, q)
  13218. } else {
  13219. q()
  13220. }
  13221. }
  13222. }
  13223. },
  13224. bindResourceStore : function(c, a) {
  13225. var b = this;
  13226. if (!a && b.resourceStore) {
  13227. if (c !== b.resourceStore && b.resourceStore.autoDestroy) {
  13228. b.resourceStore.destroy()
  13229. } else {
  13230. b.mun(b.resourceStore, {
  13231. scope : b,
  13232. datachanged : b.onResourceStoreDataChanged
  13233. })
  13234. }
  13235. if (!c) {
  13236. b.resourceStore = null
  13237. }
  13238. }
  13239. if (c) {
  13240. c = Ext.data.StoreManager.lookup(c);
  13241. b.mon(c, {
  13242. scope : b,
  13243. datachanged : b.onResourceStoreDataChanged
  13244. });
  13245. this.taskStore.setResourceStore(c)
  13246. }
  13247. b.resourceStore = c;
  13248. if (c && !a) {
  13249. b.getView().refreshKeepingScroll()
  13250. }
  13251. },
  13252. bindAssignmentStore : function(c, a) {
  13253. var b = this;
  13254. if (!a && b.assignmentStore) {
  13255. if (c !== b.assignmentStore && b.assignmentStore.autoDestroy) {
  13256. b.assignmentStore.destroy()
  13257. } else {
  13258. b.mun(b.assignmentStore, {
  13259. scope : b,
  13260. datachanged : b.onAssignmentStoreDataChanged
  13261. })
  13262. }
  13263. if (!c) {
  13264. b.assignmentStore = null
  13265. }
  13266. }
  13267. if (c) {
  13268. c = Ext.data.StoreManager.lookup(c);
  13269. b.mon(c, {
  13270. scope : b,
  13271. datachanged : b.onAssignmentStoreDataChanged
  13272. });
  13273. this.taskStore.setAssignmentStore(c)
  13274. }
  13275. b.assignmentStore = c;
  13276. if (c && !a) {
  13277. b.getView().refreshKeepingScroll()
  13278. }
  13279. },
  13280. onResourceStoreDataChanged : function() {
  13281. this.getView().refreshKeepingScroll()
  13282. },
  13283. onAssignmentStoreDataChanged : function() {
  13284. this.getView().refreshKeepingScroll()
  13285. },
  13286. expandAll : function() {
  13287. Ext.suspendLayouts();
  13288. this.callParent(arguments);
  13289. Ext.resumeLayouts()
  13290. },
  13291. collapseAll : function() {
  13292. Ext.suspendLayouts();
  13293. this.callParent(arguments);
  13294. Ext.resumeLayouts()
  13295. }
  13296. });
  13297. Ext.define("Gnt.column.EndDate", {
  13298. extend : "Ext.grid.column.Date",
  13299. alias : "widget.enddatecolumn",
  13300. requires : ["Ext.grid.CellEditor"],
  13301. text : "Finish",
  13302. width : 100,
  13303. align : "left",
  13304. task : null,
  13305. editorFormat : null,
  13306. adjustMilestones : true,
  13307. constructor : function(a) {
  13308. a = a || {};
  13309. var b = a.field || a.editor;
  13310. delete a.field;
  13311. delete a.editor;
  13312. this.field = Ext.create("Ext.grid.CellEditor", {
  13313. ignoreNoChange : true,
  13314. field : b || {
  13315. xtype : "datefield",
  13316. format : a.editorFormat || a.format || this.format
  13317. || Ext.Date.defaultFormat
  13318. },
  13319. listeners : {
  13320. beforecomplete : this.onBeforeEditComplete,
  13321. scope : this
  13322. }
  13323. });
  13324. this.callParent([a]);
  13325. this.scope = this;
  13326. this.renderer = a.renderer || this.rendererFunc;
  13327. this.editorFormat = this.editorFormat || this.format
  13328. },
  13329. beforeRender : function() {
  13330. if (!this.dataIndex) {
  13331. var a = this.up("treepanel");
  13332. this.dataIndex = a.store.model.prototype.endDateField
  13333. }
  13334. this.callParent(arguments)
  13335. },
  13336. rendererFunc : function(c, d, b) {
  13337. if (!c) {
  13338. return
  13339. }
  13340. if (!b.isEditable(this.dataIndex)) {
  13341. d.tdCls = (d.tdCls || "") + " sch-column-readonly"
  13342. }
  13343. var a = c && b.getStartDate() - c === 0;
  13344. if ((!a || this.adjustMilestones)
  13345. && c - Ext.Date.clearTime(c, true) === 0
  13346. && !Ext.Date.formatContainsHourInfo(this.format)) {
  13347. c = Sch.util.Date.add(c, Sch.util.Date.MILLI, -1)
  13348. }
  13349. return Ext.util.Format.date(c, this.format)
  13350. },
  13351. afterRender : function() {
  13352. this.callParent(arguments);
  13353. var a = this.ownerCt.up("treepanel");
  13354. a.on({
  13355. edit : this.onTreeEdit,
  13356. beforeedit : this.onBeforeTreeEdit,
  13357. scope : this
  13358. })
  13359. },
  13360. onBeforeTreeEdit : function(c) {
  13361. if (c.column === this) {
  13362. c.doNotUpdateRecord = true;
  13363. var b = this.task = c.record;
  13364. if (!b.isEditable(this.dataIndex)) {
  13365. return false
  13366. }
  13367. var d = c.value;
  13368. var a = d && b.getStartDate() - d === 0;
  13369. if (d) {
  13370. if ((!a || this.adjustMilestones)
  13371. && d - Ext.Date.clearTime(d, true) === 0
  13372. && !Ext.Date.formatContainsHourInfo(this.editorFormat)) {
  13373. d = Sch.util.Date.add(d, Sch.util.Date.MILLI, -1)
  13374. }
  13375. c.value = Ext.Date.parse(Ext.Date.format(d, this.editorFormat),
  13376. this.editorFormat)
  13377. }
  13378. }
  13379. },
  13380. onBeforeEditComplete : function(d, e, b) {
  13381. var f = Ext.Date.formatContainsHourInfo(this.editorFormat);
  13382. var a = this.task.getStartDate();
  13383. var c = b && a - b === 0;
  13384. if ((!c || this.adjustMilestones) && e && b
  13385. && b - Ext.Date.clearTime(b, true) === 0 && !f) {
  13386. e = Sch.util.Date.add(e, Sch.util.Date.DAY, 1);
  13387. return e >= this.task.getStartDate()
  13388. }
  13389. },
  13390. onTreeEdit : function(c, b) {
  13391. if (b.column === this) {
  13392. if (b.value) {
  13393. var a = b.record;
  13394. var d = b.value;
  13395. if (!Ext.Date.formatContainsHourInfo(this.editorFormat)) {
  13396. d = a.getCalendar().getCalendarDay(d)
  13397. .getAvailabilityEndFor(d)
  13398. || d
  13399. }
  13400. b.record.setEndDate(d, false)
  13401. } else {
  13402. b.record.setEndDate(null)
  13403. }
  13404. }
  13405. }
  13406. });
  13407. Ext.define("Gnt.column.PercentDone", {
  13408. extend : "Ext.grid.column.Number",
  13409. alias : "widget.percentdonecolumn",
  13410. text : "% Done",
  13411. width : 50,
  13412. format : "0",
  13413. align : "center",
  13414. field : {
  13415. xtype : "numberfield",
  13416. minValue : 0,
  13417. maxValue : 100
  13418. },
  13419. beforeRender : function() {
  13420. if (!this.dataIndex) {
  13421. var a = this.up("treepanel");
  13422. this.dataIndex = a.store.model.prototype.percentDoneField
  13423. }
  13424. this.callParent(arguments)
  13425. }
  13426. });
  13427. Ext.define("Gnt.column.StartDate", {
  13428. extend : "Ext.grid.column.Date",
  13429. alias : "widget.startdatecolumn",
  13430. text : "Start",
  13431. width : 100,
  13432. align : "left",
  13433. editorFormat : null,
  13434. adjustMilestones : true,
  13435. constructor : function(a) {
  13436. a = a || {};
  13437. var b = a.field || a.editor;
  13438. delete a.field;
  13439. delete a.editor;
  13440. this.field = Ext.create("Ext.grid.CellEditor", {
  13441. ignoreNoChange : true,
  13442. field : b || {
  13443. xtype : "datefield",
  13444. format : a.editorFormat || a.format
  13445. || this.format
  13446. || Ext.Date.defaultFormat
  13447. }
  13448. });
  13449. this.hasCustomRenderer = true;
  13450. this.callParent([a]);
  13451. this.renderer = a.renderer || this.rendererFunc;
  13452. this.editorFormat = this.editorFormat || this.format
  13453. },
  13454. beforeRender : function() {
  13455. var a = this.up("treepanel");
  13456. if (!this.dataIndex) {
  13457. this.dataIndex = a.store.model.prototype.startDateField
  13458. }
  13459. this.callParent(arguments);
  13460. a.on({
  13461. edit : this.onTreeEdit,
  13462. beforeedit : this.onBeforeTreeEdit,
  13463. scope : this
  13464. })
  13465. },
  13466. rendererFunc : function(a, d, b) {
  13467. if (!a) {
  13468. return
  13469. }
  13470. if (!b.isEditable(this.dataIndex)) {
  13471. d.tdCls = (d.tdCls || "") + " sch-column-readonly"
  13472. }
  13473. var c = b.getEndDate();
  13474. if (this.adjustMilestones && c - a === 0
  13475. && a - Ext.Date.clearTime(a, true) === 0
  13476. && !Ext.Date.formatContainsHourInfo(this.format)) {
  13477. a = Sch.util.Date.add(a, Sch.util.Date.MILLI, -1)
  13478. }
  13479. return Ext.util.Format.date(a, this.format)
  13480. },
  13481. onBeforeTreeEdit : function(c) {
  13482. if (c.column == this) {
  13483. c.doNotUpdateRecord = true;
  13484. var b = c.record;
  13485. if (!b.isEditable(this.dataIndex)) {
  13486. return false
  13487. }
  13488. var a = c.value;
  13489. if (a) {
  13490. if (this.adjustMilestones
  13491. && b.getEndDate() - b.getStartDate() === 0
  13492. && a - Ext.Date.clearTime(a, true) === 0) {
  13493. a = Sch.util.Date.add(a, Sch.util.Date.MILLI, -1)
  13494. }
  13495. c.originalEditorValue = c.value = Ext.Date.parse(
  13496. Ext.Date.format(a, this.editorFormat),
  13497. this.editorFormat)
  13498. }
  13499. }
  13500. },
  13501. onTreeEdit : function(d, c) {
  13502. var b = c.record;
  13503. var e = c.value;
  13504. var a = c.originalValue;
  13505. if (c.column == this) {
  13506. if (!e) {
  13507. b.setStartDate(null)
  13508. } else {
  13509. if (e - c.originalEditorValue !== 0) {
  13510. var f = b.getEndDate();
  13511. if (this.adjustMilestones && f
  13512. && f - b.getStartDate() === 0
  13513. && a - Ext.Date.clearTime(a, true) === 0
  13514. && e - Ext.Date.clearTime(e, true) === 0) {
  13515. e = b.getCalendar().getCalendarDay(e)
  13516. .getAvailabilityEndFor(e)
  13517. || e
  13518. }
  13519. b
  13520. .setStartDate(
  13521. e,
  13522. true,
  13523. b.getTaskStore().skipWeekendsDuringDragDrop)
  13524. }
  13525. }
  13526. }
  13527. }
  13528. });
  13529. Ext.define("Gnt.column.WBS", {
  13530. extend : "Ext.grid.column.Column",
  13531. alias : "widget.wbscolumn",
  13532. text : "#",
  13533. width : 40,
  13534. align : "left",
  13535. dataIndex : "index",
  13536. renderer : function(f, g, b, h, d, e) {
  13537. var a = e.getRootNode(), c = [];
  13538. while (b !== a) {
  13539. c.push(b.data.index + 1);
  13540. b = b.parentNode
  13541. }
  13542. return c.reverse().join(".")
  13543. }
  13544. });
  13545. Ext.define("Gnt.column.SchedulingMode", {
  13546. extend : "Ext.grid.column.Column",
  13547. alias : "widget.schedulingmodecolumn",
  13548. text : "Mode",
  13549. width : 100,
  13550. align : "left",
  13551. data : [["FixedDuration", "Fixed duration"],
  13552. ["EffortDriven", "Effort driven"],
  13553. ["DynamicAssignment", "Dynamic assignment"],
  13554. ["Manual", "Manual"], ["Normal", "Normal"]],
  13555. modeNames : null,
  13556. pickerAlign : "tl-bl?",
  13557. matchFieldWidth : true,
  13558. constructor : function(a) {
  13559. a = a || {};
  13560. var c = a.field || a.editor;
  13561. a.field = c || {
  13562. xtype : "combo",
  13563. editable : false,
  13564. store : this.data,
  13565. pickerAlign : this.pickerAlign,
  13566. matchFieldWidth : this.matchFieldWidth
  13567. };
  13568. var b = this.modeNames = {};
  13569. Ext.Array.each(this.data, function(d) {
  13570. b[d[0]] = d[1]
  13571. });
  13572. this.scope = this;
  13573. this.callParent([a])
  13574. },
  13575. beforeRender : function() {
  13576. if (!this.dataIndex) {
  13577. var a = this.up("treepanel");
  13578. this.dataIndex = a.store.model.prototype.schedulingModeField
  13579. }
  13580. this.callParent(arguments)
  13581. },
  13582. renderer : function(a) {
  13583. return this.modeNames[a]
  13584. },
  13585. afterRender : function() {
  13586. this.callParent(arguments);
  13587. this.tree = this.ownerCt.up("treepanel");
  13588. this.tree.on("edit", this.onTreeEdit, this)
  13589. },
  13590. onTreeEdit : function(b, a) {
  13591. if (a.column == this) {
  13592. a.record.setSchedulingMode(a.value)
  13593. }
  13594. }
  13595. });
  13596. Ext.define("Gnt.column.ResourceAssignment", {
  13597. extend : "Ext.grid.column.Column",
  13598. alias : "widget.resourceassignmentcolumn",
  13599. text : "Assigned Resources",
  13600. tdCls : "sch-assignment-cell",
  13601. showUnits : true,
  13602. assignmentStore : null,
  13603. initComponent : function() {
  13604. this.formatString = "{0}" + (this.showUnits ? " [{1}%]" : "");
  13605. this.callParent(arguments)
  13606. },
  13607. afterRender : function() {
  13608. this.scope = this;
  13609. this.callParent(arguments);
  13610. this.assignmentStore = this.getOwnerHeaderCt().up("ganttpanel").assignmentStore
  13611. },
  13612. renderer : function(k, o, b, h, n, m, j) {
  13613. var g = [], e = this.assignmentStore, a, f = b.getInternalId();
  13614. if (e.resourceStore.getCount() > 0) {
  13615. for (var d = 0, c = e.getCount(); d < c; d++) {
  13616. a = e.getAt(d);
  13617. if (a.getTaskId() === f) {
  13618. g.push(Ext.String.format(this.formatString, a
  13619. .getResourceName(), a.getUnits()))
  13620. }
  13621. }
  13622. return g.join(", ")
  13623. }
  13624. }
  13625. });
  13626. Ext.define("Gnt.column.ResourceName", {
  13627. extend : "Ext.grid.column.Column",
  13628. alias : "widget.resourcenamecolumn",
  13629. text : "Resource Name",
  13630. dataIndex : "ResourceName",
  13631. flex : 1,
  13632. align : "left"
  13633. });
  13634. Ext.define("Gnt.column.AssignmentUnits", {
  13635. extend : "Ext.grid.column.Number",
  13636. alias : "widget.assignmentunitscolumn",
  13637. text : "Units",
  13638. dataIndex : "Units",
  13639. format : "0 %",
  13640. align : "left"
  13641. });
  13642. Ext.define("Gnt.widget.AssignmentGrid", {
  13643. requires : ["Gnt.model.Resource", "Gnt.model.Assignment",
  13644. "Gnt.column.ResourceName", "Gnt.column.AssignmentUnits",
  13645. "Ext.grid.plugin.CellEditing"],
  13646. extend : "Ext.grid.Panel",
  13647. alias : "widget.assignmentgrid",
  13648. readOnly : false,
  13649. cls : "gnt-assignmentgrid",
  13650. defaultAssignedUnits : 100,
  13651. sorter : {
  13652. sorterFn : function(b, a) {
  13653. var d = b.getUnits(), c = a.getUnits();
  13654. if ((!d && !c) || (d && c)) {
  13655. return b.get("ResourceName") < a.get("ResourceName")
  13656. ? -1
  13657. : 1
  13658. }
  13659. return d ? -1 : 1
  13660. }
  13661. },
  13662. constructor : function(a) {
  13663. this.store = Ext.create("Ext.data.JsonStore", {
  13664. model : Ext.define("Gnt.model.AssignmentEditing", {
  13665. extend : "Gnt.model.Assignment",
  13666. fields : ["ResourceName"]
  13667. })
  13668. });
  13669. this.columns = this.buildColumns();
  13670. if (!this.readOnly) {
  13671. this.plugins = this.buildPlugins()
  13672. }
  13673. Ext.apply(this, {
  13674. selModel : {
  13675. selType : "checkboxmodel",
  13676. mode : "MULTI",
  13677. checkOnly : true,
  13678. selectByPosition : function(b) {
  13679. var c = this.store.getAt(b.row);
  13680. this.select(c, true)
  13681. }
  13682. }
  13683. });
  13684. this.callParent(arguments)
  13685. },
  13686. initComponent : function() {
  13687. this.loadResources();
  13688. this.resourceStore.on({
  13689. datachanged : this.loadResources,
  13690. scope : this
  13691. });
  13692. this.getSelectionModel().on("select", this.onSelect, this, {
  13693. delay : 50
  13694. });
  13695. this.callParent(arguments)
  13696. },
  13697. onSelect : function(b, a) {
  13698. if ((!this.cellEditing || !this.cellEditing.getActiveEditor())
  13699. && !a.getUnits()) {
  13700. a.setUnits(this.defaultAssignedUnits)
  13701. }
  13702. },
  13703. loadResources : function() {
  13704. var d = [], b = this.resourceStore, e;
  13705. for (var c = 0, a = b.getCount(); c < a; c++) {
  13706. e = b.getAt(c).getId();
  13707. d.push({
  13708. ResourceId : e,
  13709. ResourceName : b.getById(e).getName()
  13710. })
  13711. }
  13712. this.store.loadData(d)
  13713. },
  13714. buildPlugins : function() {
  13715. var a = this.cellEditing = Ext.create(
  13716. "Ext.grid.plugin.CellEditing", {
  13717. clicksToEdit : 1
  13718. });
  13719. a.on("edit", this.onEditingDone, this);
  13720. return [a]
  13721. },
  13722. hide : function() {
  13723. this.cellEditing.cancelEdit();
  13724. this.callParent(arguments)
  13725. },
  13726. onEditingDone : function(a, b) {
  13727. if (b.value) {
  13728. this.getSelectionModel().select(b.record, true)
  13729. } else {
  13730. this.getSelectionModel().deselect(b.record);
  13731. b.record.reject()
  13732. }
  13733. },
  13734. buildColumns : function() {
  13735. return [{
  13736. xtype : "resourcenamecolumn",
  13737. resourceStore : this.resourceStore
  13738. }, {
  13739. xtype : "assignmentunitscolumn",
  13740. assignmentStore : this.assignmentStore,
  13741. editor : {
  13742. xtype : "numberfield",
  13743. minValue : 0,
  13744. step : 10
  13745. }
  13746. }]
  13747. },
  13748. loadTaskAssignments : function(d) {
  13749. var b = this.store, f = this.getSelectionModel();
  13750. f.deselectAll(true);
  13751. for (var c = 0, a = b.getCount(); c < a; c++) {
  13752. b.getAt(c).data.Units = "";
  13753. b.getAt(c).data.Id = null
  13754. }
  13755. b.suspendEvents();
  13756. var e = this.assignmentStore.queryBy(function(g) {
  13757. return g.getTaskId() === d
  13758. });
  13759. e.each(function(h) {
  13760. var g = b.findRecord("ResourceId", h
  13761. .getResourceId(), 0, false, true,
  13762. true);
  13763. if (g) {
  13764. g.setUnits(h.getUnits());
  13765. g.set(g.idProperty, h.getId());
  13766. f.select(g, true, true)
  13767. }
  13768. });
  13769. b.resumeEvents();
  13770. b.sort(this.sorter);
  13771. this.getView().refresh()
  13772. }
  13773. });
  13774. Ext.define("Gnt.widget.AssignmentField", {
  13775. extend : "Ext.form.field.Picker",
  13776. alias : "widget.assignmenteditor",
  13777. requires : ["Gnt.widget.AssignmentGrid"],
  13778. matchFieldWidth : false,
  13779. editable : false,
  13780. cancelText : "Cancel",
  13781. closeText : "Save and Close",
  13782. assignmentStore : null,
  13783. resourceStore : null,
  13784. gridConfig : null,
  13785. createPicker : function() {
  13786. var a = new Gnt.widget.AssignmentGrid(Ext.apply({
  13787. ownerCt : this.ownerCt,
  13788. renderTo : document.body,
  13789. frame : true,
  13790. floating : true,
  13791. hidden : true,
  13792. height : 200,
  13793. width : 300,
  13794. resourceStore : this.resourceStore,
  13795. assignmentStore : this.assignmentStore,
  13796. fbar : this.buildButtons()
  13797. }, this.gridConfig || {}));
  13798. return a
  13799. },
  13800. buildButtons : function() {
  13801. return ["->", {
  13802. text : this.closeText,
  13803. handler : function() {
  13804. Ext.Function.defer(this.onGridClose, Ext.isIE
  13805. && !Ext.isIE9 ? 60 : 30, this)
  13806. },
  13807. scope : this
  13808. }, {
  13809. text : this.cancelText,
  13810. handler : this.collapse,
  13811. scope : this
  13812. }]
  13813. },
  13814. onExpand : function() {
  13815. var a = this.resourceStore, b = this.picker;
  13816. b.loadTaskAssignments(this.taskId)
  13817. },
  13818. onGridClose : function() {
  13819. var b = this.picker.getSelectionModel(), a = b.selected;
  13820. this.fireEvent("select", this, a);
  13821. this.collapse()
  13822. },
  13823. collapseIf : function(b) {
  13824. var a = this;
  13825. if (this.picker && !b.getTarget(".x-editor")
  13826. && !b.getTarget(".x-menu-item")) {
  13827. a.callParent(arguments)
  13828. }
  13829. },
  13830. mimicBlur : function(b) {
  13831. var a = this;
  13832. if (!b.getTarget(".x-editor") && !b.getTarget(".x-menu-item")) {
  13833. a.callParent(arguments)
  13834. }
  13835. }
  13836. });
  13837. Ext.define("Gnt.widget.AssignmentCellEditor", {
  13838. extend : "Ext.grid.CellEditor",
  13839. requires : ["Gnt.model.Assignment", "Gnt.widget.AssignmentField"],
  13840. assignmentStore : null,
  13841. resourceStore : null,
  13842. taskId : null,
  13843. fieldConfig : null,
  13844. allowBlur : false,
  13845. constructor : function(a) {
  13846. a = a || {};
  13847. var b = a.fieldConfig || {};
  13848. this.field = Ext.create("Gnt.widget.AssignmentField", Ext
  13849. .apply(b, {
  13850. assignmentStore : a.assignmentStore,
  13851. resourceStore : a.resourceStore
  13852. }));
  13853. this.field.on({
  13854. select : this.onSelect,
  13855. collapse : this.cancelEdit,
  13856. scope : this
  13857. });
  13858. this.callParent(arguments)
  13859. },
  13860. startEdit : function(c, d, b) {
  13861. this.parentEl = null;
  13862. var a = c.child("div").dom.innerHTML;
  13863. this.taskId = this.field.taskId = b.record.getInternalId();
  13864. this.callParent([c, a === "&nbsp;" ? "" : a]);
  13865. this.field.expand()
  13866. },
  13867. onSelect : function(g, c) {
  13868. this.completeEdit();
  13869. var a = this.assignmentStore, f = this.taskId;
  13870. var e = {};
  13871. var d = [];
  13872. c.each(function(i) {
  13873. var h = i.getUnits();
  13874. if (h > 0) {
  13875. var k = i.getId();
  13876. if (k) {
  13877. e[k] = true;
  13878. a.getById(k).setUnits(h)
  13879. } else {
  13880. var j = Ext.create(a.model);
  13881. j.setTaskId(f);
  13882. j.setResourceId(i.getResourceId());
  13883. j.setUnits(h);
  13884. e[j.internalId] = true;
  13885. d.push(j)
  13886. }
  13887. }
  13888. });
  13889. var b = [];
  13890. a.each(function(h) {
  13891. if (h.getTaskId() === f
  13892. && !e[h.getId() || h.internalId]) {
  13893. b.push(h)
  13894. }
  13895. });
  13896. a.remove(b);
  13897. a.add(d)
  13898. }
  13899. });
  13900. Ext.define("Gnt.widget.DependencyField", {
  13901. extend : "Ext.form.field.Text",
  13902. alias : "widget.dependencyfield",
  13903. requires : ["Gnt.util.DependencyParser"],
  13904. constructor : function(a) {
  13905. var b = this;
  13906. Ext.apply(this, a);
  13907. this.dependencyParser = new Gnt.util.DependencyParser({
  13908. parseNumberFn : function() {
  13909. return Gnt.widget.DurationField.prototype.parseValue
  13910. .apply(b, arguments)
  13911. }
  13912. });
  13913. this.callParent(arguments)
  13914. },
  13915. getDependencies : function() {
  13916. return this.dependencyParser.parse(this.getRawValue())
  13917. },
  13918. getErrors : function(b) {
  13919. if (!b) {
  13920. return
  13921. }
  13922. var a = this.dependencyParser.parse(b);
  13923. if (!a) {
  13924. return ["Invalid dependency format"]
  13925. }
  13926. return this.callParent([a.value])
  13927. }
  13928. });
  13929. Ext.define("Gnt.widget.DependencyEditor", {
  13930. extend : "Ext.grid.CellEditor",
  13931. alias : ["widget.dependencyeditor"],
  13932. context : null,
  13933. taskStore : null,
  13934. dependencyStore : null,
  13935. type : "predecessors",
  13936. constructor : function(a) {
  13937. a = a || {};
  13938. Ext.apply(this, a);
  13939. a.field = a.field || Ext.create("Gnt.widget.DependencyField", {});
  13940. this.callParent([a])
  13941. },
  13942. startEdit : function(b, c, a) {
  13943. this.context = a;
  13944. var d = b.hasCls(".x-grid-cell-inner") ? b : b
  13945. .down(".x-grid-cell-inner");
  13946. c = Ext.String.trim(d.dom.innerText || d.dom.innerHTML).replace(
  13947. "&nbsp;", "");
  13948. return this.callParent([b, c, a])
  13949. },
  13950. completeEdit : function(a) {
  13951. var b = this, e = b.field, d;
  13952. if (!b.editing) {
  13953. return
  13954. }
  13955. d = b.getValue();
  13956. if (!e.isValid()) {
  13957. if (b.revertInvalid !== false) {
  13958. b.cancelEdit(a)
  13959. }
  13960. return
  13961. }
  13962. if (String(d) === String(b.startValue) && b.ignoreNoChange) {
  13963. b.hideEdit(a);
  13964. return
  13965. }
  13966. if (b.fireEvent("beforecomplete", b, d, b.startValue) !== false) {
  13967. d = b.getValue();
  13968. if (b.updateEl && b.boundEl) {
  13969. b.boundEl.update(d)
  13970. }
  13971. var c = this.field.getDependencies();
  13972. if (this.validateDependencies(c)) {
  13973. this.processDependencies(c);
  13974. b.hideEdit(a);
  13975. b.fireEvent("complete", b, d, b.startValue)
  13976. }
  13977. }
  13978. },
  13979. validateDependencies : function(e) {
  13980. var a = this.type === "predecessors";
  13981. for (var d = 0; d < e.length; d++) {
  13982. var c = a ? e[d].taskId : this.context.record.getInternalId();
  13983. var b = !a ? e[d].taskId : this.context.record.getInternalId();
  13984. if (!this.taskStore.getById(e[d].taskId)
  13985. || (!this.dependencyStore.areTasksLinked(c, b) && !this.dependencyStore
  13986. .isValidDependency(c, b))) {
  13987. return false
  13988. }
  13989. }
  13990. return true
  13991. },
  13992. processDependencies : function(h) {
  13993. var m = this.dependencyStore, d = this.context, e = d.record, a = Ext.Array
  13994. .pluck(h, "taskId"), k = this.type === "predecessors", l = k
  13995. ? e.getIncomingDependencies()
  13996. : e.getOutgoingDependencies(), c = [];
  13997. for (var g = 0; g < l.length; g++) {
  13998. if (!Ext.Array.contains(a,
  13999. l[g][k ? "getSourceId" : "getTargetId"]())) {
  14000. c.push(l[g])
  14001. }
  14002. }
  14003. if (c.length > 0) {
  14004. m.remove(c)
  14005. }
  14006. var n = [];
  14007. for (g = 0; g < h.length; g++) {
  14008. var f = h[g];
  14009. var b = f.taskId;
  14010. var j = m.getByTaskIds(b, e.getInternalId());
  14011. if (j) {
  14012. j.beginEdit();
  14013. j.setType(f.type);
  14014. j.setLag(f.lag);
  14015. j.setLagUnit(f.lagUnit);
  14016. j.endEdit()
  14017. } else {
  14018. n.push(new m.model({
  14019. fromTask : k ? b : e.getInternalId(),
  14020. toTask : k ? e.getInternalId() : b,
  14021. type : f.type,
  14022. lag : f.lag,
  14023. lagUnit : f.lagUnit
  14024. }))
  14025. }
  14026. }
  14027. if (n.length > 0) {
  14028. m.add(n)
  14029. }
  14030. if (n.length || c.length) {
  14031. e.afterEdit(["--dependency--"])
  14032. }
  14033. }
  14034. });
  14035. Ext.define("Gnt.widget.DurationField", {
  14036. extend : "Ext.form.field.Number",
  14037. requires : ["Gnt.util.DurationParser"],
  14038. alias : "widget.durationfield",
  14039. alternateClassName : "Gnt.column.duration.Field",
  14040. disableKeyFilter : true,
  14041. minValue : 0,
  14042. durationUnit : "h",
  14043. invalidText : "Invalid duration value",
  14044. useAbbreviation : false,
  14045. durationParser : null,
  14046. durationParserConfig : null,
  14047. constructor : function(a) {
  14048. var b = this;
  14049. Ext.apply(this, a);
  14050. this.durationParser = new Gnt.util.DurationParser(Ext.apply({
  14051. parseNumberFn : function() {
  14052. return b.parseValue.apply(b, arguments)
  14053. },
  14054. allowDecimals : this.decimalPrecision > 0
  14055. }, this.durationParserConfig));
  14056. this.callParent(arguments)
  14057. },
  14058. rawToValue : function(b) {
  14059. var a = this.parseDuration(b);
  14060. if (!a) {
  14061. return null
  14062. }
  14063. this.durationUnit = a.unit;
  14064. return a.value != null ? a.value : null
  14065. },
  14066. valueToRaw : function(a) {
  14067. if (Ext.isNumber(a)) {
  14068. return parseFloat(Ext.Number.toFixed(a,
  14069. this.decimalPrecision))
  14070. + " "
  14071. + Sch.util.Date[this.useAbbreviation
  14072. ? "getShortNameOfUnit"
  14073. : "getReadableNameOfUnit"](
  14074. this.durationUnit, a !== 1)
  14075. }
  14076. return ""
  14077. },
  14078. parseDuration : function(b) {
  14079. if (b == null) {
  14080. return null
  14081. }
  14082. var a = this;
  14083. var c = this.durationParser.parse(b);
  14084. if (!c) {
  14085. return null
  14086. }
  14087. c.unit = c.unit || this.durationUnit;
  14088. return c
  14089. },
  14090. getDurationValue : function() {
  14091. var a = this;
  14092. return this.parseDuration(this.getRawValue())
  14093. },
  14094. getErrors : function(b) {
  14095. var a = this.parseDuration(b);
  14096. if (!a) {
  14097. return [this.invalidText]
  14098. }
  14099. return this.callParent([a.value])
  14100. },
  14101. checkChange : function() {
  14102. if (!this.suspendCheckChange) {
  14103. var d = this, c = d.getDurationValue(), a = d.lastValue;
  14104. var b = c && !a || !c && a || c && a
  14105. && (c.value != a.value || c.unit != a.unit);
  14106. if (b && !d.isDestroyed) {
  14107. d.lastValue = c;
  14108. d.fireEvent("change", d, c, a);
  14109. d.onChange(c, a)
  14110. }
  14111. }
  14112. }
  14113. });
  14114. Ext.define("Gnt.widget.DurationEditor", {
  14115. extend : "Ext.grid.CellEditor",
  14116. alias : ["widget.durationeditor", "widget.durationcolumneditor"],
  14117. alternateClassName : "Gnt.column.duration.Editor",
  14118. context : null,
  14119. decimalPrecision : 2,
  14120. getDurationUnitMethod : "getDurationUnit",
  14121. setDurationMethod : "setDuration",
  14122. useAbbreviation : false,
  14123. constructor : function(a) {
  14124. a = a || {};
  14125. Ext.apply(this, a);
  14126. a.field = a.field || Ext.create("Gnt.widget.DurationField", {
  14127. useAbbreviation : this.useAbbreviation,
  14128. decimalPrecision : this.decimalPrecision
  14129. });
  14130. this.callParent([a])
  14131. },
  14132. startEdit : function(c, b, a) {
  14133. this.context = a;
  14134. this.field.durationUnit = a.record[this.getDurationUnitMethod]();
  14135. return this.callParent(arguments)
  14136. },
  14137. completeEdit : function(a) {
  14138. var d = this, g = d.field, e;
  14139. if (!d.editing) {
  14140. return
  14141. }
  14142. if (g.assertValue) {
  14143. g.assertValue()
  14144. }
  14145. e = d.getValue();
  14146. if (!g.isValid()) {
  14147. if (d.revertInvalid !== false) {
  14148. d.cancelEdit(a)
  14149. }
  14150. return
  14151. }
  14152. if (String(e) === String(d.startValue) && d.ignoreNoChange) {
  14153. d.hideEdit(a);
  14154. return
  14155. }
  14156. if (d.fireEvent("beforecomplete", d, e, d.startValue) !== false) {
  14157. e = d.getValue();
  14158. if (d.updateEl && d.boundEl) {
  14159. d.boundEl.update(e)
  14160. }
  14161. d.hideEdit(a);
  14162. var c = this.context;
  14163. var b = c.record;
  14164. var f = this.field.getDurationValue();
  14165. b[this.setDurationMethod](f.value, f.unit);
  14166. d.fireEvent("complete", d, e, d.startValue)
  14167. }
  14168. }
  14169. });
  14170. Ext.define("Gnt.column.Dependency", {
  14171. extend : "Ext.grid.column.Column",
  14172. requires : ["Gnt.widget.DependencyField", "Gnt.widget.DependencyEditor"],
  14173. separator : ";",
  14174. type : "predecessors",
  14175. dataIndex : "--dependency--",
  14176. constructor : function(a) {
  14177. a = a || {};
  14178. Ext.apply(this, a);
  14179. a.editor = a.editor || Ext.create("Gnt.widget.DependencyEditor", {
  14180. type : this.type
  14181. });
  14182. if (!a.editor.isFormField) {
  14183. a.editor = Ext.ComponentManager
  14184. .create(a.editor, "dependencyeditor")
  14185. }
  14186. this.scope = this;
  14187. this.callParent([a])
  14188. },
  14189. beforeRender : function() {
  14190. var a = this.up("ganttpanel");
  14191. a.registerLockedDependencyListeners();
  14192. this.dependencyStore = a.getDependencyStore();
  14193. if (this.editor) {
  14194. this.editor.taskStore = a.getTaskStore();
  14195. this.editor.dependencyStore = a.getDependencyStore()
  14196. }
  14197. this.callParent(arguments)
  14198. },
  14199. renderer : function(j, n, a) {
  14200. if (!a.isEditable(this.dataIndex)) {
  14201. n.tdCls = (n.tdCls || "") + " sch-column-readonly"
  14202. }
  14203. var h = this.type === "predecessors", m = this.getDependencies(a), k = Gnt.util.DependencyParser.prototype.types, e = Gnt.model.Dependency.Type.EndToStart, l = [];
  14204. for (var d = 0; d < m.length; d++) {
  14205. var g = m[d];
  14206. if (g.isValid(false)) {
  14207. var f = g.getType(), b = g.getLag(), c = g.getLagUnit();
  14208. l.push(Ext.String.format("{0}{1}{2}{3}{4}", h
  14209. ? g.getSourceId()
  14210. : g.getTargetId(), b || f !== e ? k[f] : "", b
  14211. ? "+"
  14212. : "", b || "", b && c !== "d" ? c : ""))
  14213. }
  14214. }
  14215. return l.join(this.separator)
  14216. }
  14217. });
  14218. Ext.define("Gnt.column.Successor", {
  14219. extend : "Gnt.column.Dependency",
  14220. alias : "widget.successorcolumn",
  14221. text : "Successors",
  14222. type : "successors",
  14223. getDependencies : function(a) {
  14224. return a.getOutgoingDependencies()
  14225. }
  14226. });
  14227. Ext.define("Gnt.column.Predecessor", {
  14228. extend : "Gnt.column.Dependency",
  14229. alias : "widget.predecessorcolumn",
  14230. text : "Predecessors",
  14231. type : "predecessors",
  14232. getDependencies : function(a) {
  14233. return a.getIncomingDependencies()
  14234. }
  14235. });
  14236. Ext.define("Gnt.column.Duration", {
  14237. extend : "Ext.grid.column.Column",
  14238. alias : "widget.durationcolumn",
  14239. requires : ["Gnt.widget.DurationField", "Gnt.widget.DurationEditor"],
  14240. text : "Duration",
  14241. width : 80,
  14242. align : "left",
  14243. decimalPrecision : 2,
  14244. getDurationUnitMethod : "getDurationUnit",
  14245. setDurationMethod : "setDuration",
  14246. useAbbreviation : false,
  14247. constructor : function(a) {
  14248. a = a || {};
  14249. Ext.apply(this, a);
  14250. a.editor = a.editor
  14251. || Ext.create("Gnt.widget.DurationEditor", {
  14252. useAbbreviation : this.useAbbreviation,
  14253. decimalPrecision : this.decimalPrecision,
  14254. getDurationUnitMethod : this.getDurationUnitMethod,
  14255. setDurationMethod : this.setDurationMethod
  14256. });
  14257. if (!a.editor.isFormField) {
  14258. a.editor = Ext.ComponentManager.create(a.editor,
  14259. "durationcolumneditor")
  14260. }
  14261. this.scope = this;
  14262. this.callParent([a]);
  14263. this.mon(this.editor, "beforestartedit",
  14264. this.onBeforeStartEdit, this)
  14265. },
  14266. beforeRender : function() {
  14267. if (!this.dataIndex) {
  14268. var a = this.up("treepanel");
  14269. this.dataIndex = a.store.model.prototype.durationField
  14270. }
  14271. this.callParent(arguments)
  14272. },
  14273. onBeforeStartEdit : function(b) {
  14274. var a = b.context.record;
  14275. return a.isEditable(this.dataIndex)
  14276. },
  14277. renderer : function(b, c, a) {
  14278. if (!Ext.isNumber(b)) {
  14279. return ""
  14280. }
  14281. if (!a.isEditable(this.dataIndex)) {
  14282. c.tdCls = (c.tdCls || "") + " sch-column-readonly"
  14283. }
  14284. b = parseFloat(Ext.Number.toFixed(b, this.decimalPrecision));
  14285. return b
  14286. + " "
  14287. + Sch.util.Date[this.useAbbreviation
  14288. ? "getShortNameOfUnit"
  14289. : "getReadableNameOfUnit"](
  14290. a[this.getDurationUnitMethod](), b !== 1)
  14291. }
  14292. });
  14293. Ext.define("Gnt.column.Effort", {
  14294. extend : "Gnt.column.Duration",
  14295. alias : "widget.effortcolumn",
  14296. text : "Effort",
  14297. getDurationUnitMethod : "getEffortUnit",
  14298. setDurationMethod : "setEffort",
  14299. beforeRender : function() {
  14300. if (!this.dataIndex) {
  14301. var a = this.up("treepanel");
  14302. this.dataIndex = a.store.model.prototype.effortField
  14303. }
  14304. this.callParent(arguments)
  14305. }
  14306. });
  14307. Ext.define("Gnt.widget.Calendar", {
  14308. extend : "Ext.picker.Date",
  14309. alias : "widget.ganttcalendar",
  14310. requires : ["Gnt.data.Calendar", "Sch.util.Date"],
  14311. calendar : null,
  14312. startDate : null,
  14313. endDate : null,
  14314. disabledDatesText : "Holiday",
  14315. initComponent : function() {
  14316. if (!this.calendar) {
  14317. Ext.Error
  14318. .raise('Required attribute "calendar" missing during initialization of `Gnt.widget.Calendar`')
  14319. }
  14320. if (!this.startDate) {
  14321. Ext.Error
  14322. .raise('Required attribute "startDate" missing during initialization of `Gnt.widget.Calendar`')
  14323. }
  14324. if (!this.endDate) {
  14325. this.endDate = Sch.util.Date.add(this.startDate,
  14326. Sch.util.Date.MONTH, 1)
  14327. }
  14328. this.setCalendar(this.calendar);
  14329. this.minDate = this.value = this.startDate;
  14330. this.injectDates();
  14331. this.callParent(arguments)
  14332. },
  14333. injectDates : function() {
  14334. var a = this;
  14335. var b = a.disabledDates = [];
  14336. Ext.each(a.calendar.getHolidaysRanges(a.startDate, a.endDate),
  14337. function(c) {
  14338. c.forEachDate(function(d) {
  14339. b.push(Ext.Date.format(d, a.format))
  14340. })
  14341. });
  14342. a.setDisabledDates(b)
  14343. },
  14344. setCalendar : function(b) {
  14345. var a = {
  14346. update : this.injectDates,
  14347. remove : this.injectDates,
  14348. add : this.injectDates,
  14349. load : this.injectDates,
  14350. clear : this.injectDates,
  14351. scope : this
  14352. };
  14353. if (this.calendar) {
  14354. this.calendar.un(a)
  14355. }
  14356. this.calendar = b;
  14357. b.on(a)
  14358. }
  14359. });
  14360. Ext.define("Gnt.widget.calendar.DayGrid", {
  14361. extend : "Ext.grid.Panel",
  14362. title : "Day overrides",
  14363. height : 180,
  14364. nameText : "Name",
  14365. dateText : "Date",
  14366. noNameText : "[Day override]",
  14367. initComponent : function() {
  14368. Ext.applyIf(this, {
  14369. store : Ext.create("Gnt.data.Calendar", {
  14370. proxy : "memory"
  14371. }),
  14372. plugins : [Ext.create(
  14373. "Ext.grid.plugin.CellEditing", {
  14374. clicksToEdit : 2
  14375. })],
  14376. columns : [{
  14377. header : this.nameText,
  14378. dataIndex : "Name",
  14379. flex : 1,
  14380. editor : {
  14381. allowBlank : false
  14382. }
  14383. }, {
  14384. header : this.dateText,
  14385. dataIndex : "Date",
  14386. width : 100,
  14387. xtype : "datecolumn",
  14388. editor : {
  14389. xtype : "datefield"
  14390. }
  14391. }]
  14392. });
  14393. this.callParent(arguments)
  14394. }
  14395. });
  14396. Ext.define("Gnt.widget.calendar.WeekGrid", {
  14397. extend : "Ext.grid.Panel",
  14398. requires : ["Gnt.model.WeekAvailability"],
  14399. title : "Week overrides",
  14400. border : true,
  14401. height : 220,
  14402. nameText : "Name",
  14403. startDateText : "Start date",
  14404. endDateText : "End date",
  14405. initComponent : function() {
  14406. Ext.applyIf(this, {
  14407. store : Ext.create("Ext.data.Store", {
  14408. model : "Gnt.model.WeekAvailability",
  14409. proxy : "memory"
  14410. })
  14411. });
  14412. Ext.applyIf(this, {
  14413. columns : [{
  14414. header : this.nameText,
  14415. dataIndex : this.store.model.prototype.nameField,
  14416. flex : 1,
  14417. editor : {
  14418. allowBlank : false
  14419. }
  14420. }, {
  14421. header : this.startDateText,
  14422. dataIndex : this.store.model.prototype.startDateField,
  14423. width : 100,
  14424. xtype : "datecolumn",
  14425. editor : {
  14426. xtype : "datefield"
  14427. }
  14428. }, {
  14429. header : this.endDateText,
  14430. dataIndex : this.store.model.prototype.endDateField,
  14431. width : 100,
  14432. xtype : "datecolumn",
  14433. editor : {
  14434. xtype : "datefield"
  14435. }
  14436. }],
  14437. plugins : [Ext.create("Ext.grid.plugin.CellEditing", {
  14438. clicksToEdit : 2
  14439. })]
  14440. });
  14441. this.callParent(arguments)
  14442. }
  14443. });
  14444. Ext.define("Gnt.widget.calendar.ResourceCalendarGrid", {
  14445. extend : "Ext.grid.Panel",
  14446. requires : ["Gnt.data.Calendar", "Sch.util.Date"],
  14447. alias : "widget.resourcecalendargrid",
  14448. resourceStore : null,
  14449. calendarStore : null,
  14450. initComponent : function() {
  14451. var a = this;
  14452. this.calendarStore = this.calendarStore
  14453. || Ext.create("Ext.data.Store", {
  14454. fields : ["Id", "Name"]
  14455. });
  14456. Ext.apply(a, {
  14457. store : a.resourceStore,
  14458. columns : [{
  14459. header : "Name",
  14460. dataIndex : "Name",
  14461. flex : 1
  14462. }, {
  14463. header : "Calendar",
  14464. dataIndex : "CalendarId",
  14465. flex : 1,
  14466. renderer : function(f, h, b, e, d, c) {
  14467. if (!f) {
  14468. var g = b.getCalendar();
  14469. f = g ? g.calendarId : ""
  14470. }
  14471. var i = a.calendarStore.getById(f);
  14472. return i ? i.get("Name") : f
  14473. },
  14474. editor : {
  14475. xtype : "combobox",
  14476. store : a.calendarStore,
  14477. queryMode : "local",
  14478. displayField : "Name",
  14479. valueField : "Id",
  14480. editable : false,
  14481. allowBlank : false
  14482. }
  14483. }],
  14484. border : true,
  14485. height : 180,
  14486. plugins : [Ext.create(
  14487. "Ext.grid.plugin.CellEditing", {
  14488. clicksToEdit : 2
  14489. })]
  14490. });
  14491. this.calendarStore.loadData(this.getCalendarData());
  14492. this.callParent(arguments)
  14493. },
  14494. getCalendarData : function() {
  14495. var a = [];
  14496. Ext.Array.each(Gnt.data.Calendar.getAllCalendars(),
  14497. function(b) {
  14498. a.push({
  14499. Id : b.calendarId,
  14500. Name : b.name || b.calendarId
  14501. })
  14502. });
  14503. return a
  14504. }
  14505. });
  14506. Ext.define("Gnt.widget.calendar.DayAvailabilityGrid", {
  14507. extend : "Ext.grid.Panel",
  14508. requires : ["Gnt.data.Calendar", "Sch.util.Date"],
  14509. alias : "widget.dayavailabilitygrid",
  14510. height : 160,
  14511. calendarDay : null,
  14512. startText : "Start",
  14513. endText : "End",
  14514. addText : "Add",
  14515. removeText : "Remove",
  14516. workingTimeText : "Working time",
  14517. nonworkingTimeText : "Non-working time",
  14518. getDayTypeRadioGroup : function() {
  14519. return this.down('radiogroup[name="dayType"]')
  14520. },
  14521. initComponent : function() {
  14522. Ext.applyIf(this, {
  14523. store : Ext.create("Ext.data.Store", {
  14524. fields : ["startTime", "endTime"],
  14525. proxy : {
  14526. type : "memory",
  14527. reader : {
  14528. type : "json"
  14529. }
  14530. }
  14531. }),
  14532. plugins : [Ext.create("Ext.grid.plugin.CellEditing", {
  14533. clicksToEdit : 2
  14534. })],
  14535. dockedItems : [{
  14536. xtype : "radiogroup",
  14537. dock : "top",
  14538. name : "dayType",
  14539. padding : "0 5px",
  14540. margin : 0,
  14541. items : [{
  14542. boxLabel : this.workingTimeText,
  14543. name : "IsWorkingDay",
  14544. inputValue : true
  14545. }, {
  14546. boxLabel : this.nonworkingTimeText,
  14547. name : "IsWorkingDay",
  14548. inputValue : false
  14549. }],
  14550. listeners : {
  14551. change : this.onDayTypeChanged,
  14552. scope : this
  14553. }
  14554. }],
  14555. tbar : this.buildToolbar(),
  14556. columns : [{
  14557. header : this.startText,
  14558. xtype : "datecolumn",
  14559. format : "g:i a",
  14560. dataIndex : "startTime",
  14561. flex : 1,
  14562. editor : {
  14563. xtype : "timefield",
  14564. allowBlank : false,
  14565. initDate : "31/12/1899"
  14566. }
  14567. }, {
  14568. header : this.endText,
  14569. xtype : "datecolumn",
  14570. format : "g:i a",
  14571. dataIndex : "endTime",
  14572. flex : 1,
  14573. editor : {
  14574. allowBlank : false,
  14575. xtype : "timefield",
  14576. initDate : "31/12/1899"
  14577. }
  14578. }],
  14579. listeners : {
  14580. selectionchange : this.onAvailabilityGridSelectionChange,
  14581. scope : this
  14582. }
  14583. });
  14584. this.callParent(arguments)
  14585. },
  14586. buildToolbar : function() {
  14587. this.addButton = new Ext.Button({
  14588. text : this.addText,
  14589. iconCls : "gnt-action-add",
  14590. handler : this.addAvailability,
  14591. scope : this
  14592. });
  14593. this.removeButton = new Ext.Button({
  14594. text : this.removeText,
  14595. iconCls : "gnt-action-remove",
  14596. handler : this.removeAvailability,
  14597. scope : this,
  14598. disabled : true
  14599. });
  14600. return [this.addButton, this.removeButton]
  14601. },
  14602. onAvailabilityGridSelectionChange : function(a) {
  14603. if (this.removeButton) {
  14604. this.removeButton.setDisabled(!a || a.getSelection().length === 0)
  14605. }
  14606. },
  14607. onDayTypeChanged : function(a) {
  14608. var b = a.getValue();
  14609. if (Ext.isArray(b.IsWorkingDay)) {
  14610. return
  14611. }
  14612. this.getView().setDisabled(!b.IsWorkingDay)
  14613. },
  14614. addAvailability : function() {
  14615. var a = this.getStore(), b = a.count();
  14616. if (b >= 5) {
  14617. return
  14618. }
  14619. a.add({
  14620. startTime : new Date(0, 0, 0, 12, 0),
  14621. endTime : new Date(0, 0, 0, 13, 0)
  14622. });
  14623. if (b + 1 >= 5 && this.addButton) {
  14624. this.addButton.setDisabled(true)
  14625. }
  14626. },
  14627. removeAvailability : function() {
  14628. var b = this.getStore(), c = b.count(), d = this.getSelectionModel();
  14629. if (!d || d.getSelection().length === 0) {
  14630. return
  14631. }
  14632. var a = d.getSelection()[0];
  14633. b.remove(a);
  14634. if (c < 5 && this.addButton) {
  14635. this.addButton.setDisabled(false)
  14636. }
  14637. },
  14638. editAvailability : function(a) {
  14639. this.calendarDay = a;
  14640. this.getDayTypeRadioGroup().setValue({
  14641. IsWorkingDay : a.getIsWorkingDay()
  14642. });
  14643. var b = this.calendarDay.getAvailability();
  14644. this.getStore().loadData(b)
  14645. },
  14646. isWorkingDay : function() {
  14647. return this.getDayTypeRadioGroup().getValue().IsWorkingDay
  14648. },
  14649. isValid : function() {
  14650. var c = this.getDayTypeRadioGroup().getValue().IsWorkingDay, b = [];
  14651. if (c) {
  14652. try {
  14653. b = this.getIntervals();
  14654. this.calendarDay.verifyAvailability(b)
  14655. } catch (a) {
  14656. Ext.MessageBox.alert("Error", a);
  14657. return false
  14658. }
  14659. }
  14660. return true
  14661. },
  14662. getIntervals : function() {
  14663. var a = [];
  14664. this.getStore().each(function(b) {
  14665. a.push({
  14666. startTime : b.get("startTime"),
  14667. endTime : b.get("endTime")
  14668. })
  14669. });
  14670. return a
  14671. }
  14672. });
  14673. Ext.define("Gnt.widget.calendar.WeekEditor", {
  14674. extend : "Ext.form.Panel",
  14675. requires : ["Ext.grid.*", "Gnt.data.Calendar", "Sch.util.Date"],
  14676. alias : "widget.calendarweekeditor",
  14677. layout : "anchor",
  14678. defaults : {
  14679. border : false,
  14680. anchor : "100%"
  14681. },
  14682. getDefaultWeekAvailabilityHandler : null,
  14683. startDate : null,
  14684. endDate : null,
  14685. startHeaderText : "Start",
  14686. endHeaderText : "End",
  14687. defaultTimeText : "Default time",
  14688. workingTimeText : "Working time",
  14689. nonworkingTimeText : "Non-working time",
  14690. addText : "Add",
  14691. removeText : "Remove",
  14692. weekAvailability : null,
  14693. currentWeekDay : null,
  14694. _weekDaysGrid : null,
  14695. getWeekDaysGrid : function() {
  14696. if (this._weekDaysGrid != null) {
  14697. return this._weekDaysGrid
  14698. }
  14699. var a = Ext.Date.dayNames;
  14700. return this._weekDaysGrid = Ext.create("Ext.grid.Panel", {
  14701. hideHeaders : true,
  14702. height : 160,
  14703. columns : [{
  14704. header : "",
  14705. dataIndex : "name",
  14706. flex : 1
  14707. }],
  14708. store : Ext.create("Ext.data.JsonStore", {
  14709. fields : ["id", "name"],
  14710. idProperty : "id",
  14711. data : [{
  14712. id : 1,
  14713. name : a[1]
  14714. }, {
  14715. id : 2,
  14716. name : a[2]
  14717. }, {
  14718. id : 3,
  14719. name : a[3]
  14720. }, {
  14721. id : 4,
  14722. name : a[4]
  14723. }, {
  14724. id : 5,
  14725. name : a[5]
  14726. }, {
  14727. id : 6,
  14728. name : a[6]
  14729. }, {
  14730. id : 0,
  14731. name : a[0]
  14732. }]
  14733. }),
  14734. listeners : {
  14735. selectionchange : {
  14736. fn : this.onWeekDaysListSelectionChange,
  14737. scope : this
  14738. }
  14739. }
  14740. })
  14741. },
  14742. _availabilityGrid : null,
  14743. getAvailabilityGrid : function() {
  14744. if (!this._availabilityGrid) {
  14745. this._availabilityGrid = Ext.create("Ext.grid.Panel", {
  14746. height : 160,
  14747. plugins : [Ext.create("Ext.grid.plugin.CellEditing", {
  14748. clicksToEdit : 2
  14749. })],
  14750. tbar : [{
  14751. text : this.addText,
  14752. action : "add",
  14753. handler : this.addAvailability,
  14754. scope : this,
  14755. iconCls : "gnt-action-add"
  14756. }, {
  14757. text : this.removeText,
  14758. iconCls : "gnt-action-remove",
  14759. action : "remove",
  14760. handler : this.removeAvailability,
  14761. scope : this
  14762. }],
  14763. store : Ext.create("Ext.data.Store", {
  14764. fields : ["startTime", "endTime"],
  14765. proxy : {
  14766. type : "memory",
  14767. reader : {
  14768. type : "json"
  14769. }
  14770. }
  14771. }),
  14772. columns : [{
  14773. header : this.startHeaderText,
  14774. xtype : "datecolumn",
  14775. format : "g:i a",
  14776. dataIndex : "startTime",
  14777. flex : 1,
  14778. editor : {
  14779. xtype : "timefield",
  14780. allowBlank : false,
  14781. initDate : "31/12/1899"
  14782. }
  14783. }, {
  14784. header : this.endHeaderText,
  14785. xtype : "datecolumn",
  14786. format : "g:i a",
  14787. dataIndex : "endTime",
  14788. flex : 1,
  14789. editor : {
  14790. allowBlank : false,
  14791. xtype : "timefield",
  14792. initDate : "31/12/1899"
  14793. }
  14794. }],
  14795. listeners : {
  14796. selectionchange : this.onAvailabilityGridSelectionChange,
  14797. scope : this
  14798. }
  14799. })
  14800. }
  14801. return this._availabilityGrid
  14802. },
  14803. getDayTypeRadioGroup : function() {
  14804. return this.down('radiogroup[name="dayType"]')
  14805. },
  14806. initComponent : function() {
  14807. if (!this.getDefaultWeekAvailabilityHandler
  14808. && !Ext.isFunction(this.getDefaultWeekAvailabilityHandler)) {
  14809. Ext.Error
  14810. .raise('Required attribute "getDefaultWeekAvailabilityHandler" is missed during initialization of `Gnt.widget.calendar.WeekEditor`')
  14811. }
  14812. this.items = [{
  14813. xtype : "radiogroup",
  14814. padding : "0 5px",
  14815. name : "dayType",
  14816. items : [{
  14817. boxLabel : this.defaultTimeText,
  14818. name : "IsWorkingDay",
  14819. inputValue : 0
  14820. }, {
  14821. boxLabel : this.workingTimeText,
  14822. name : "IsWorkingDay",
  14823. inputValue : 1
  14824. }, {
  14825. boxLabel : this.nonworkingTimeText,
  14826. name : "IsWorkingDay",
  14827. inputValue : 2
  14828. }],
  14829. listeners : {
  14830. change : {
  14831. fn : this.onDayTypeChanged,
  14832. scope : this
  14833. }
  14834. }
  14835. }, {
  14836. layout : "column",
  14837. padding : "0 0 5px 0",
  14838. defaults : {
  14839. border : false
  14840. },
  14841. items : [{
  14842. margin : "0 10px 0 5px",
  14843. columnWidth : 0.5,
  14844. items : this.getWeekDaysGrid()
  14845. }, {
  14846. columnWidth : 0.5,
  14847. margin : "0 5px 0 0",
  14848. items : this.getAvailabilityGrid()
  14849. }]
  14850. }];
  14851. this.callParent(arguments)
  14852. },
  14853. addAvailability : function() {
  14854. var b = this.getAvailabilityGrid(), a = b.getStore(), c = a.count();
  14855. if (c >= 5) {
  14856. return
  14857. }
  14858. a.add({
  14859. startTime : new Date(0, 0, 0, 12, 0),
  14860. endTime : new Date(0, 0, 0, 13, 0)
  14861. });
  14862. if (c + 1 >= 5) {
  14863. b.down('button[action="add"]').setDisabled(true)
  14864. }
  14865. },
  14866. removeAvailability : function() {
  14867. var c = this.getAvailabilityGrid(), b = c.getStore(), d = b.count(), e = c
  14868. .getSelectionModel();
  14869. if (!e || e.getSelection().length === 0) {
  14870. return
  14871. }
  14872. var a = e.getSelection()[0];
  14873. b.remove(a);
  14874. if (d < 5) {
  14875. c.down('button[action="add"]').setDisabled(false)
  14876. }
  14877. },
  14878. editAvailability : function(b, e, a) {
  14879. this.startDate = b;
  14880. this.endDate = e;
  14881. this.weekAvailability = a;
  14882. var c = this.getWeekDaysGrid(), d = c.getStore().getAt(0);
  14883. c.getSelectionModel().select(d, false, true);
  14884. this.refreshView(d)
  14885. },
  14886. applyChanges : function(a) {
  14887. if (!this.validateAndSave()) {
  14888. return false
  14889. }
  14890. if (a && Ext.isFunction(a)) {
  14891. a.call(this, this.weekAvailability)
  14892. }
  14893. },
  14894. getIntervals : function() {
  14895. var a = [];
  14896. this.getAvailabilityGrid().getStore().each(function(b) {
  14897. a.push({
  14898. startTime : b.get("startTime"),
  14899. endTime : b.get("endTime")
  14900. })
  14901. });
  14902. return a
  14903. },
  14904. onWeekDaysListSelectionChange : function(a, b) {
  14905. if (!this.validateAndSave()) {
  14906. return false
  14907. }
  14908. this.refreshView(b[0])
  14909. },
  14910. validateAndSave : function() {
  14911. var c = this.currentWeekDay.get("IsWorkingDay"), b = [];
  14912. if (c) {
  14913. try {
  14914. b = this.getIntervals();
  14915. this.currentWeekDay.verifyAvailability(b)
  14916. } catch (a) {
  14917. Ext.MessageBox.alert("Error", a);
  14918. return false
  14919. }
  14920. }
  14921. this.currentWeekDay.setAvailability(b);
  14922. return true
  14923. },
  14924. refreshView : function(d) {
  14925. var g = d.getId(), b = this.weekAvailability[g], f = this
  14926. .getDayTypeRadioGroup(), e = b.getAvailability(), c = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
  14927. .exec(b.getId()), a = !c ? 0 : (b.get("IsWorkingDay") ? 1 : 2);
  14928. this.currentWeekDay = b;
  14929. f.setValue({
  14930. IsWorkingDay : [a]
  14931. });
  14932. this.getAvailabilityGrid().getStore().loadData(e)
  14933. },
  14934. onAvailabilityGridSelectionChange : function(b) {
  14935. var a = this.getAvailabilityGrid();
  14936. a.down('button[action="remove"]').setDisabled(!b
  14937. || b.getSelection().length === 0)
  14938. },
  14939. onDayTypeChanged : function(g) {
  14940. var c = g.getValue();
  14941. if (Ext.isArray(c.IsWorkingDay)) {
  14942. return
  14943. }
  14944. var a = this.getWeekDaysGrid(), d = a.getSelectionModel(), b = d
  14945. .getSelection()[0].getId(), e = this.weekAvailability[b]
  14946. .get("Name"), f = [], i = Ext.Date.format(this.startDate,
  14947. "Y/m/d"), j = Ext.Date.format(this.endDate, "Y/m/d");
  14948. switch (c.IsWorkingDay) {
  14949. case 0 :
  14950. var h = this.getDefaultWeekAvailabilityHandler()[b];
  14951. h.set("Name", e);
  14952. h.set("Date", null);
  14953. f = h.getAvailability();
  14954. this.weekAvailability[b] = h;
  14955. break;
  14956. default :
  14957. f = this.weekAvailability[b].getAvailability();
  14958. this.currentWeekDay.set("Id", Ext.String.format("{0}-{1}-{2}",
  14959. b, i, j));
  14960. this.currentWeekDay.set("IsWorkingDay", c.IsWorkingDay === 1);
  14961. break
  14962. }
  14963. this.getAvailabilityGrid().getStore().loadData(Ext.clone(f));
  14964. this.getAvailabilityGrid().setDisabled(c.IsWorkingDay !== 1)
  14965. }
  14966. });
  14967. Ext.define("Gnt.widget.calendar.DatePicker", {
  14968. extend : "Ext.picker.Date",
  14969. alias : "widget.gntdatepicker",
  14970. calendar : null,
  14971. workingDayCls : "gnt-datepicker-workingday",
  14972. nonWorkingDayCls : "gnt-datepicker-nonworkingday",
  14973. overriddenDayCls : "gnt-datepicker-overriddenday",
  14974. overriddenWeekDayCls : "gnt-datepicker-overriddenweekday",
  14975. _weeks : null,
  14976. getWeekOverrides : function() {
  14977. return this._weeks
  14978. },
  14979. setWeekOverrides : function(a) {
  14980. this._weeks = a
  14981. },
  14982. _days : null,
  14983. getDayOverrides : function() {
  14984. return this._days
  14985. },
  14986. setDayOverrides : function(a) {
  14987. this._days = a
  14988. },
  14989. update : function(b, e) {
  14990. var d = this, c = 0, a = d.cells.elements;
  14991. this.removeCustomCls();
  14992. this.callParent(arguments);
  14993. for (; c < d.numDays; ++c) {
  14994. b = a[c].firstChild.dateValue;
  14995. a[c].className += " " + this.getDateCls(b)
  14996. }
  14997. },
  14998. getDateCls : function(d) {
  14999. var b = "", f = 0, g = this;
  15000. d = new Date(d);
  15001. if (d.getMonth() !== this.getActive().getMonth()) {
  15002. return
  15003. }
  15004. if (this.getDayOverrides().getOverrideDay(d)) {
  15005. b += (" " + this.overriddenDayCls);
  15006. if (!this.getDayOverrides().isWorkingDay(d)) {
  15007. b += (" " + this.nonWorkingDayCls)
  15008. }
  15009. } else {
  15010. var e = null;
  15011. this.getWeekOverrides().each(function(h) {
  15012. if (Ext.Date.between(d, h.getStartDate(), h
  15013. .getEndDate())) {
  15014. e = h;
  15015. return true
  15016. }
  15017. });
  15018. if (e) {
  15019. b += (" " + this.overriddenWeekDayCls);
  15020. var c = new Date(d).getDay(), a = e.getAvailability();
  15021. if (a && a[c] && a[c].getIsWorkingDay() === false) {
  15022. b += (" " + g.nonWorkingDayCls)
  15023. }
  15024. } else {
  15025. if (!this.getDayOverrides().isWorkingDay(d)) {
  15026. b += (" " + this.nonWorkingDayCls)
  15027. }
  15028. }
  15029. }
  15030. return b.length > 0 ? b : this.workingDayCls
  15031. },
  15032. removeCustomCls : function() {
  15033. this.cells.removeCls([this.overriddenDayCls,
  15034. this.nonWorkingDayCls, this.workingDayCls,
  15035. this.overriddenWeekDayCls])
  15036. }
  15037. });
  15038. Ext.define("Gnt.widget.calendar.Calendar", {
  15039. extend : "Ext.form.Panel",
  15040. requires : ["Ext.XTemplate", "Gnt.data.Calendar",
  15041. "Gnt.widget.calendar.DayGrid", "Gnt.widget.calendar.WeekGrid",
  15042. "Gnt.widget.calendar.DayAvailabilityGrid",
  15043. "Gnt.widget.calendar.WeekEditor", "Gnt.widget.calendar.DatePicker"],
  15044. alias : "widget.calendar",
  15045. defaults : {
  15046. padding : 10,
  15047. border : false
  15048. },
  15049. workingDayCls : "gnt-datepicker-workingday",
  15050. nonWorkingDayCls : "gnt-datepicker-nonworkingday",
  15051. overriddenDayCls : "gnt-datepicker-overriddenday",
  15052. overriddenWeekDayCls : "gnt-datepicker-overriddenweekday",
  15053. calendar : null,
  15054. dayOverrideNameHeaderText : "Name",
  15055. dateText : "Date",
  15056. addText : "Add",
  15057. editText : "Edit",
  15058. removeText : "Remove",
  15059. workingDayText : "Working day",
  15060. weekendsText : "Weekends",
  15061. overriddenDayText : "Overridden day",
  15062. overriddenWeekText : "Overridden week",
  15063. defaultTimeText : "Default time",
  15064. workingTimeText : "Working time",
  15065. nonworkingTimeText : "Non-working time",
  15066. dayGridConfig : null,
  15067. weekGridConfig : null,
  15068. datePickerConfig : null,
  15069. dayOverridesText : "Day overrides",
  15070. weekOverridesText : "Week overrides",
  15071. okText : "OK",
  15072. cancelText : "Cancel",
  15073. calendarNameText : "Calendar name",
  15074. tplTexts : {
  15075. tplWorkingHours : "Working hours for",
  15076. tplIsNonWorking : "is non-working",
  15077. tplOverride : "override",
  15078. tplInCalendar : "in calendar",
  15079. tplDayInCalendar : "standard day in calendar"
  15080. },
  15081. parentCalendarText : "Parent calendar",
  15082. noParentText : "No parent",
  15083. selectParentText : "Select parent",
  15084. newDayName : "[Without name]",
  15085. overrideErrorText : "There is already an override for this day",
  15086. intersectDatesErrorText : "Dates shouldn't intersect",
  15087. startDateErrorText : "StartDate greater then EndDate",
  15088. dayGrid : null,
  15089. weekGrid : null,
  15090. getDayGrid : function() {
  15091. if (!this.dayGrid) {
  15092. this.dayGrid = Ext.create("Gnt.widget.calendar.DayGrid", Ext.apply(
  15093. {
  15094. tbar : [{
  15095. text : this.addText,
  15096. action : "add",
  15097. iconCls : "gnt-action-add",
  15098. handler : this.addDay,
  15099. scope : this
  15100. }, {
  15101. text : this.editText,
  15102. action : "edit",
  15103. iconCls : "gnt-action-edit",
  15104. handler : this.editDay,
  15105. scope : this
  15106. }, {
  15107. text : this.removeText,
  15108. action : "remove",
  15109. iconCls : "gnt-action-remove",
  15110. handler : this.removeDay,
  15111. scope : this
  15112. }]
  15113. }, this.dayGridConfig || {}))
  15114. }
  15115. return this.dayGrid
  15116. },
  15117. getWeekGrid : function() {
  15118. if (!this.weekGrid) {
  15119. this.weekGrid = Ext.create("Gnt.widget.calendar.WeekGrid", Ext
  15120. .apply({
  15121. tbar : [{
  15122. text : this.addText,
  15123. action : "add",
  15124. iconCls : "gnt-action-add",
  15125. handler : this.addWeek,
  15126. scope : this
  15127. }, {
  15128. text : this.editText,
  15129. action : "edit",
  15130. iconCls : "gnt-action-edit",
  15131. handler : this.editWeek,
  15132. scope : this
  15133. }, {
  15134. text : this.removeText,
  15135. action : "remove",
  15136. iconCls : "gnt-action-remove",
  15137. handler : this.removeWeek,
  15138. scope : this
  15139. }]
  15140. }, this.weekGridConfig || {}))
  15141. }
  15142. return this.weekGrid
  15143. },
  15144. datePicker : null,
  15145. getDatePicker : function() {
  15146. if (!this.datePicker) {
  15147. this.datePicker = Ext.create("Gnt.widget.calendar.DatePicker",
  15148. this.datePickerConfig || {})
  15149. }
  15150. return this.datePicker
  15151. },
  15152. 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>',
  15153. dateInfoTpl : null,
  15154. initComponent : function() {
  15155. var d = this;
  15156. if (!(this.legendTpl instanceof Ext.Template)) {
  15157. this.legendTpl = new Ext.XTemplate(this.legendTpl)
  15158. }
  15159. if (!(this.dateInfoTpl instanceof Ext.Template)) {
  15160. this.dateInfoTpl = new Ext.XTemplate(this.dateInfoTpl)
  15161. }
  15162. if (!this.calendar) {
  15163. Ext.Error
  15164. .raise('Required attribute "calendar" is missed during initialization of `Gnt.widget.Calendar`')
  15165. }
  15166. d.setupTemplates();
  15167. var b = this.getWeekGrid(), a = this.getDayGrid(), c = this
  15168. .getDatePicker();
  15169. this.dayGrid.on({
  15170. selectionchange : this.onDayGridSelectionChange,
  15171. validateedit : this.onDayGridValidateEdit,
  15172. edit : this.onDayGridEdit,
  15173. scope : this
  15174. });
  15175. this.dayGrid.store.on({
  15176. update : this.refreshView,
  15177. remove : this.refreshView,
  15178. add : this.refreshView,
  15179. scope : this
  15180. });
  15181. this.weekGrid.on({
  15182. selectionchange : this.onWeekGridSelectionChange,
  15183. validateedit : this.onWeekGridValidateEdit,
  15184. edit : this.onWeekGridEdit,
  15185. scope : this
  15186. });
  15187. this.weekGrid.store.on({
  15188. update : this.refreshView,
  15189. remove : this.refreshView,
  15190. add : this.refreshView,
  15191. scope : this
  15192. });
  15193. this.datePicker.on({
  15194. select : this.onDateSelect,
  15195. scope : this
  15196. });
  15197. this.fillDaysStore();
  15198. this.fillWeeksStore();
  15199. c.setWeekOverrides(b.getStore());
  15200. c.setDayOverrides(a.getStore());
  15201. this.dateInfoPanel = new Ext.Panel({
  15202. cls : "gnt-calendar-dateinfo",
  15203. columnWidth : 0.33,
  15204. border : false,
  15205. height : 200
  15206. });
  15207. this.items = [{
  15208. xtype : "container",
  15209. layout : "hbox",
  15210. pack : "start",
  15211. align : "stretch",
  15212. items : [{
  15213. html : Ext.String.format('{0}: "{1}"', this.calendarNameText,
  15214. this.calendar.name),
  15215. border : false,
  15216. flex : 1
  15217. }, {
  15218. xtype : "combobox",
  15219. name : "cmb_parentCalendar",
  15220. fieldLabel : d.parentCalendarText,
  15221. store : Ext.create("Ext.data.Store", {
  15222. fields : ["Id", "Name"],
  15223. data : [{
  15224. Id : -1,
  15225. Name : d.noParentText
  15226. }].concat(d.calendar
  15227. .getParentableCalendars())
  15228. }),
  15229. queryMode : "local",
  15230. displayField : "Name",
  15231. valueField : "Id",
  15232. editable : false,
  15233. emptyText : d.selectParentText,
  15234. value : d.calendar.parent ? d.calendar.parent.calendarId : -1,
  15235. flex : 1
  15236. }]
  15237. }, {
  15238. layout : "column",
  15239. defaults : {
  15240. border : false
  15241. },
  15242. items : [{
  15243. margin : "0 15px 0 0",
  15244. columnWidth : 0.3,
  15245. html : this.legendTpl.apply({
  15246. workingDayText : this.workingDayText,
  15247. weekendsText : this.weekendsText,
  15248. overriddenDayText : this.overriddenDayText,
  15249. overriddenWeekText : this.overriddenWeekText,
  15250. workingDayCls : this.workingDayCls,
  15251. nonWorkingDayCls : this.nonWorkingDayCls,
  15252. overriddenDayCls : this.overriddenDayCls,
  15253. overriddenWeekDayCls : this.overriddenWeekDayCls
  15254. })
  15255. }, {
  15256. columnWidth : 0.37,
  15257. margin : "0 5px 0 0",
  15258. items : c
  15259. }, this.dateInfoPanel]
  15260. }, {
  15261. xtype : "tabpanel",
  15262. items : [a, b]
  15263. }];
  15264. this.callParent(arguments)
  15265. },
  15266. setupTemplates : function() {
  15267. var a = this, b = [a.tplTexts[0], a.tplTexts[1], a.tplTexts[2],
  15268. a.tplTexts[3], a.tplTexts[4]];
  15269. this.dateInfoTpl = this.dateInfoTpl
  15270. || Ext.String.format(['<tpl if="isWorkingDay == true">',
  15271. "<div>{0} {date}:</div>", "</tpl>",
  15272. '<tpl if="isWorkingDay == false">',
  15273. "<div>{date} {1}</div>", "</tpl>",
  15274. '<ul class="gnt-calendar-availabilities">',
  15275. '<tpl for="availability">', "<li>{.}</li>",
  15276. "</tpl>", "</ul>", "<span>Based on: ",
  15277. '<tpl if="override == true">',
  15278. '{2} "{name}" {3} "{calendarName}"', "</tpl>",
  15279. '<tpl if="override == false">',
  15280. '{4} "{calendarName}"', "</tpl>", "</span>"]
  15281. .join(""), b)
  15282. },
  15283. onRender : function() {
  15284. this.onDateSelect(this.getDatePicker(), new Date());
  15285. this.callParent(arguments)
  15286. },
  15287. fillDaysStore : function() {
  15288. var a = [];
  15289. this.calendar.each(function(b) {
  15290. if (!b.getDate()) {
  15291. return
  15292. }
  15293. a.push(Ext.create("Gnt.model.CalendarDay", {
  15294. Date : b.getDate(),
  15295. Id : b.getId(),
  15296. Name : b.getName(),
  15297. IsWorkingDay : b.getIsWorkingDay(),
  15298. Availability : b.getAvailability()
  15299. }))
  15300. });
  15301. this.getDayGrid().getStore().loadData(a)
  15302. },
  15303. fillWeeksStore : function() {
  15304. var d = [], c = this, b = this.getWeekGrid().store.model.prototype, a;
  15305. Ext.Array.each(this.calendar.nonStandardWeeksStartDates, function(f) {
  15306. var h = c.calendar.getNonStandardWeekByStartDate(f);
  15307. var g = {};
  15308. var e = c.calendar.getDefaultWeekAvailability();
  15309. g[b.nameField] = h.name;
  15310. g[b.startDateField] = h.startDate;
  15311. g[b.endDateField] = h.endDate;
  15312. g[b.availabilityField] = e;
  15313. Ext.Array.each(e, function(i) {
  15314. i.setName(h.name);
  15315. i.clearDate(null)
  15316. });
  15317. Ext.Array.each(h.weekAvailability, function(k, l) {
  15318. if (k) {
  15319. var m = k.getId();
  15320. var j = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
  15321. .exec(m);
  15322. if (!j) {
  15323. return
  15324. }
  15325. var i = j[1];
  15326. a = Ext.create("Gnt.model.CalendarDay");
  15327. a.clearDate(null);
  15328. a.setId(m);
  15329. a.setName(h.name);
  15330. a.setIsWorkingDay(k.getIsWorkingDay());
  15331. a.setAvailability(k.getAvailability())
  15332. } else {
  15333. a = c.calendar.getDefaultCalendarDay(l)
  15334. }
  15335. e[l] = a
  15336. });
  15337. d.push(g)
  15338. });
  15339. this.getWeekGrid().getStore().loadData(d)
  15340. },
  15341. reload : function() {
  15342. var b = this.getWeekGrid(), a = this.getDayGrid();
  15343. this.fillDaysStore();
  15344. this.fillWeeksStore();
  15345. this.getDatePicker().setWeekOverrides(b.getStore());
  15346. this.getDatePicker().setDayOverrides(a.getStore())
  15347. },
  15348. editDay : function() {
  15349. var c = this, e = this.getDayGrid().getSelectionModel();
  15350. if (!e || e.getSelection().length === 0) {
  15351. return
  15352. }
  15353. var a = e.getSelection()[0];
  15354. var b = new Gnt.widget.calendar.DayAvailabilityGrid({
  15355. addText : this.addText,
  15356. removeText : this.removeText,
  15357. workingTimeText : this.workingTimeText,
  15358. nonworkingTimeText : this.nonworkingTimeText
  15359. });
  15360. var d = Ext.create("Ext.window.Window", {
  15361. title : this.dayOverridesText,
  15362. modal : true,
  15363. width : 280,
  15364. height : 260,
  15365. layout : "fit",
  15366. items : b,
  15367. buttons : [{
  15368. text : this.okText,
  15369. handler : function() {
  15370. c.calendar.clearCache();
  15371. if (b.isValid()) {
  15372. var f = b.calendarDay;
  15373. f.setIsWorkingDay(b.isWorkingDay());
  15374. f.setAvailability(b.getIntervals());
  15375. c.applyCalendarDay(f, a);
  15376. c.refreshView();
  15377. d.close()
  15378. }
  15379. }
  15380. }, {
  15381. text : this.cancelText,
  15382. handler : function() {
  15383. d.close()
  15384. }
  15385. }]
  15386. });
  15387. b.editAvailability(this.cloneCalendarDay(a));
  15388. d.show()
  15389. },
  15390. addDay : function() {
  15391. var a = this.getDatePicker().getValue(), b = this.getDayGrid(), c = Ext
  15392. .create("Gnt.model.CalendarDay", {
  15393. Name : this.newDayName,
  15394. Cls : this.calendar.defaultNonWorkingTimeCssCls,
  15395. Date : a,
  15396. IsWorkingDay : false
  15397. });
  15398. b.getStore().insert(0, c);
  15399. b.getSelectionModel().select([c], false, false)
  15400. },
  15401. removeDay : function() {
  15402. var f = this.getDayGrid(), h = f.getSelectionModel(), c = f.getStore();
  15403. if (!h || h.getSelection().length === 0) {
  15404. return
  15405. }
  15406. c.clearCache();
  15407. var a = h.getSelection()[0], d = this.getDatePicker().getValue(), g = d
  15408. .getDay(), b = this.getWeekOverrideDay(d), e = b != null;
  15409. c.remove(a);
  15410. if (b == null) {
  15411. b = this.calendar.defaultWeekAvailability[g]
  15412. }
  15413. this.getDatePicker().setValue(d)
  15414. },
  15415. refreshView : function() {
  15416. var e = this.getDatePicker().getValue(), b = this.getCalendarDay(e), d = this
  15417. .getWeekGrid(), a = this.getDayGrid(), c = a.getStore()
  15418. .getOverrideDay(e), g;
  15419. if (c) {
  15420. a.getSelectionModel().select([c], false, true)
  15421. } else {
  15422. g = this.getWeekOverrideByDate(e);
  15423. if (g) {
  15424. d.getSelectionModel().select([g], false, true)
  15425. }
  15426. }
  15427. var f = {
  15428. name : b.getName(),
  15429. date : Ext.Date.format(e, "M j, Y"),
  15430. calendarName : this.calendar.name || this.calendar.calendarId,
  15431. availability : b.getAvailability(true),
  15432. override : !!(c || g),
  15433. isWorkingDay : b.getIsWorkingDay()
  15434. };
  15435. this.dateInfoPanel.update(this.dateInfoTpl.apply(f))
  15436. },
  15437. onDayGridSelectionChange : function(d) {
  15438. if (!d || d.getSelection().length === 0) {
  15439. return
  15440. }
  15441. var a = d.getSelection()[0], b = a.getDate(), c = this.getDayGrid();
  15442. this.getDatePicker().setValue(b)
  15443. },
  15444. onDayGridEdit : function(b, c) {
  15445. if (c.field === "Date") {
  15446. var a = Ext.Date.clearTime(c.value, true);
  15447. c.record.data[c.record.idProperty] = a - 0;
  15448. c.grid.getStore().clearCache();
  15449. this.getDatePicker().setValue(c.value)
  15450. }
  15451. this.refreshView()
  15452. },
  15453. onDayGridValidateEdit : function(b, c) {
  15454. var a = c.grid.getStore();
  15455. if (c.field === a.model.prototype.dateField
  15456. && a.getOverrideDay(c.value) && c.value !== c.originalValue) {
  15457. Ext.MessageBox.alert("Error", this.overrideErrorText);
  15458. return false
  15459. }
  15460. },
  15461. onDateSelect : function(b, a) {
  15462. this.refreshView()
  15463. },
  15464. getCalendarDay : function(b) {
  15465. var a = this.getOverrideDay(b);
  15466. if (a) {
  15467. return a
  15468. }
  15469. a = this.getWeekOverrideDay(b);
  15470. if (a) {
  15471. return a
  15472. }
  15473. return this.calendar.defaultWeekAvailability[b.getDay()]
  15474. },
  15475. getOverrideDay : function(a) {
  15476. return this.getDayGrid().getStore().getOverrideDay(a)
  15477. },
  15478. getWeekOverrideDay : function(c) {
  15479. var e = new Date(c), d = this.getWeekOverrideByDate(c), b = e.getDay();
  15480. if (d == null) {
  15481. return null
  15482. }
  15483. var a = d.getAvailability();
  15484. if (!a) {
  15485. return null
  15486. }
  15487. return a[b]
  15488. },
  15489. getWeekOverrideByDate : function(a) {
  15490. var b = null;
  15491. this.getWeekGrid().getStore().each(function(c) {
  15492. if (Ext.Date.between(a, c.getStartDate(), c.getEndDate())) {
  15493. b = c;
  15494. return true
  15495. }
  15496. });
  15497. return b
  15498. },
  15499. editWeek : function() {
  15500. var f = this.getWeekGrid().getSelectionModel(), c = this;
  15501. if (!f || f.getSelection().length === 0) {
  15502. return
  15503. }
  15504. var b = f.getSelection()[0];
  15505. var a = new Gnt.widget.calendar.WeekEditor({
  15506. getDefaultWeekAvailabilityHandler : function() {
  15507. return c.getDefaultWeekAvailability()
  15508. }
  15509. });
  15510. var e = Ext.create("Ext.window.Window", {
  15511. title : this.weekOverridesText,
  15512. modal : true,
  15513. width : 370,
  15514. defaults : {
  15515. border : false
  15516. },
  15517. layout : "fit",
  15518. items : a,
  15519. buttons : [{
  15520. text : this.okText,
  15521. handler : function() {
  15522. c.calendar.clearCache();
  15523. a.applyChanges(function(g) {
  15524. b.setAvailability(g);
  15525. var i = c.getDatePicker().getValue(), h = g[i.getDay()];
  15526. c.refreshView();
  15527. e.close()
  15528. })
  15529. }
  15530. }, {
  15531. text : this.cancelText,
  15532. handler : function() {
  15533. e.close()
  15534. }
  15535. }]
  15536. });
  15537. var d = [];
  15538. Ext.Array.each(b.getAvailability(), function(g) {
  15539. d.push(c.cloneCalendarDay(g))
  15540. });
  15541. e.show();
  15542. e.down("calendarweekeditor").editAvailability(b.getStartDate(),
  15543. b.getEndDate(), d)
  15544. },
  15545. addWeek : function() {
  15546. var a = this.getWeekGrid().getStore();
  15547. var b = this.getDatePicker().getValue(), c = new a.model();
  15548. c.setName(this.newDayName);
  15549. c.setStartDate(b);
  15550. c.setEndDate(b);
  15551. c.setAvailability(this.calendar.getDefaultWeekAvailability());
  15552. a.insert(0, c);
  15553. this.getWeekGrid().getSelectionModel().select([c], false, false)
  15554. },
  15555. removeWeek : function() {
  15556. var f = this.getWeekGrid().getSelectionModel();
  15557. if (!f || f.getSelection().length === 0) {
  15558. return
  15559. }
  15560. var a = f.getSelection()[0], c = this.getDatePicker().getValue(), e = c
  15561. .getDay(), b = this.getOverrideDay(c), d = !!b;
  15562. b = b || this.calendar.defaultWeekAvailability[e];
  15563. this.getWeekGrid().getStore().remove(a);
  15564. this.getDatePicker().setValue(c);
  15565. this.refreshView()
  15566. },
  15567. onWeekGridSelectionChange : function(c) {
  15568. if (!c || c.getSelection().length === 0) {
  15569. return
  15570. }
  15571. var a = c.getSelection()[0], b = a.getStartDate();
  15572. this.getDatePicker().setValue(b)
  15573. },
  15574. onWeekGridEdit : function(f, g) {
  15575. var c = g.record, a = c.getStartDate(), d = c.getEndDate(), b = c
  15576. .getAvailability(), j = g.grid.getStore().model.prototype;
  15577. if (g.field == j.startDateField || g.field == j.endDateField) {
  15578. var h = Ext.Date.format(a, "Y/m/d");
  15579. var i = Ext.Date.format(d, "Y/m/d");
  15580. Ext.Array.each(b, function(k) {
  15581. var l = k.getId();
  15582. var e = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
  15583. .exec(l);
  15584. if (!e) {
  15585. return
  15586. }
  15587. k.set("Id", Ext.String
  15588. .format("{0}-{1}-{2}", e[1], h, i))
  15589. });
  15590. this.getDatePicker().setValue(a)
  15591. }
  15592. this.refreshView()
  15593. },
  15594. onWeekGridValidateEdit : function(d, f) {
  15595. var g = this, b = f.record, a = b.getStartDate(), c = b.getEndDate(), h = true, i = f.grid
  15596. .getStore(), j = i.model.prototype;
  15597. if ((f.field === j.startDateField && c < f.value || f.field === j.endDateField
  15598. && a > f.value)) {
  15599. Ext.MessageBox.alert("Error", g.startDateErrorText);
  15600. return false
  15601. }
  15602. i.each(function(k) {
  15603. var l = k.getStartDate(), e = k.getEndDate();
  15604. if (l == a && e == c) {
  15605. return
  15606. }
  15607. if ((f.field == j.startDateField && l < a && f.value <= e)
  15608. || (f.field == j.endDateField && e > c && f.value >= l)) {
  15609. h = false;
  15610. return true
  15611. }
  15612. });
  15613. if (!h) {
  15614. Ext.MessageBox.alert("Error", g.intersectDatesErrorText);
  15615. return false
  15616. }
  15617. },
  15618. applyChanges : function(b) {
  15619. var a = this.down('combobox[name="cmb_parentCalendar"]').getValue();
  15620. this.calendar.parent = a ? Gnt.data.Calendar.getCalendar(a) : null;
  15621. this.calendar.proxy.extraParams.parentId = this.calendar.parent
  15622. ? this.calendar.parent.calendarId
  15623. : null;
  15624. this.applyDays();
  15625. this.applyWeeks();
  15626. if (b && Ext.isFunction(b)) {
  15627. b.call(this, this.calendar)
  15628. }
  15629. },
  15630. applyCalendarDay : function(b, a) {
  15631. a.beginEdit();
  15632. a.setId(b.getId());
  15633. a.setName(b.getName());
  15634. a.setIsWorkingDay(b.getIsWorkingDay());
  15635. a.setDate(b.getDate());
  15636. a.setAvailability(b.getAvailability());
  15637. a.endEdit()
  15638. },
  15639. applyWeek : function(d, c) {
  15640. var b = this, a = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/;
  15641. Ext.Array.each(d.getAvailability(), function(f, h) {
  15642. var i = false, g = f.getId(), e = a.exec(g) ? false : true;
  15643. Ext.Array.each(c.weekAvailability, function(j) {
  15644. var l = j.getId(), k = a.exec(l);
  15645. if (k[1] == h) {
  15646. if (e) {
  15647. b.calendar.remove(j)
  15648. } else {
  15649. b.applyCalendarDay(f, j)
  15650. }
  15651. i = true;
  15652. return i
  15653. }
  15654. });
  15655. if (!i && !e) {
  15656. b.calendar.add(f)
  15657. }
  15658. })
  15659. },
  15660. applyWeeks : function() {
  15661. var c = this, b = this.getWeekGrid().getStore(), a = [], e = [], d = [];
  15662. Ext.Array.each(this.calendar.nonStandardWeeksStartDates, function(f) {
  15663. var g = false;
  15664. b.each(function(i) {
  15665. var h = Ext.Date.clearTime(i.getStartDate());
  15666. if (h === f) {
  15667. var j = c.calendar
  15668. .getNonStandardWeekByDate(f);
  15669. j.endDate == i.getEndDate() ? e
  15670. .push([i, j]) : a.push(f);
  15671. g = true;
  15672. return true
  15673. }
  15674. });
  15675. if (!g) {
  15676. a.push(f)
  15677. }
  15678. });
  15679. b.each(function(f) {
  15680. if (c.calendar
  15681. .getNonStandardWeekByDate(f.getStartDate() == null)) {
  15682. d.push(f)
  15683. }
  15684. });
  15685. Ext.Array.each(a, function(f) {
  15686. c.calendar.removeNonStandardWeek(f)
  15687. });
  15688. Ext.Array.each(d, function(f) {
  15689. c.calendar.addNonStandardWeek(f.getStartDate(), f
  15690. .getEndDate(), f.getAvailability())
  15691. });
  15692. Ext.Array.each(e, function(f) {
  15693. c.applyWeek(f[0], f[1])
  15694. })
  15695. },
  15696. applyDays : function() {
  15697. var c = this, b = this.getDayGrid().getStore(), a = [], e = [], d = [];
  15698. this.calendar.each(function(f) {
  15699. var g = /^(\d)-(\d\d\d\d\/\d\d\/\d\d)-(\d\d\d\d\/\d\d\/\d\d)$/
  15700. .exec(f.getId());
  15701. if (g) {
  15702. return
  15703. }
  15704. b.getOverrideDay(f.getDate()) == null ? a.push(f) : e
  15705. .push(f)
  15706. });
  15707. b.each(function(f) {
  15708. if (c.calendar.getOverrideDay(f.getDate()) == null) {
  15709. d.push(f)
  15710. }
  15711. });
  15712. this.calendar.remove(a);
  15713. this.calendar.add(d);
  15714. Ext.Array.each(e, function(f) {
  15715. var g = b.getOverrideDay(f.getDate());
  15716. c.applyCalendarDay(g, f)
  15717. })
  15718. },
  15719. cloneCalendarDay : function(a) {
  15720. return Ext.create("Gnt.model.CalendarDay", {
  15721. Date : a.getDate(),
  15722. Id : a.getId(),
  15723. Name : a.getName(),
  15724. IsWorkingDay : a.getIsWorkingDay(),
  15725. Availability : a.getAvailability()
  15726. })
  15727. },
  15728. getDefaultWeekAvailability : function() {
  15729. return this.calendar.defaultWeekAvailability
  15730. },
  15731. onDestroy : function() {
  15732. this.getWeekGrid().destroy();
  15733. this.getDayGrid().destroy();
  15734. this.getDatePicker().destroy();
  15735. this.callParent(arguments)
  15736. }
  15737. });
  15738. /*Ext.onReady(function() {
  15739. if (window.location.href.match("bryntum.com|ext-scheduler.com")) {
  15740. return
  15741. } else {
  15742. if (Sch && Sch.view && Sch.view.TimelineGridView) {
  15743. var b = false;
  15744. Sch.view.TimelineGridView.override({
  15745. refresh : function() {
  15746. this.callOverridden(arguments);
  15747. if (b || !this.rendered) {
  15748. return
  15749. }
  15750. b = true;
  15751. Ext.Function.defer(function() {
  15752. this.el.select(this.eventSelector)
  15753. .setOpacity(0.15)
  15754. }, 10 * 60 * 1000, this);
  15755. var c = this.el.parent().createChild({
  15756. tag : "a",
  15757. href : "http://www.bryntum.com/store",
  15758. title : "Click here to purchase a license",
  15759. 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;"
  15760. });
  15761. try {
  15762. if (!Ext.util.Cookies.get("bmeval")) {
  15763. Ext.util.Cookies.set("bmeval",
  15764. new Date().getTime(), Ext.Date.add(
  15765. new Date(), Ext.Date.YEAR, 2))
  15766. } else {
  15767. var g = Ext.util.Cookies.get("bmeval"), d = new Date(parseInt(
  15768. g, 10));
  15769. if (Ext.Date.add(d, Ext.Date.DAY, 45) < new Date()) {
  15770. this.el.select(this.eventSelector).hide();
  15771. this.el.mask("Trial Period Expired!").setStyle(
  15772. "z-index", 10000);
  15773. this.refresh = Ext.emptyFn
  15774. }
  15775. }
  15776. } catch (f) {
  15777. }
  15778. }
  15779. })
  15780. }
  15781. if (Sch && Sch.view && Sch.view.TimelineTreeView) {
  15782. var a = false;
  15783. Sch.view.TimelineTreeView.override({
  15784. refresh : function() {
  15785. this.callOverridden(arguments);
  15786. if (a || !this.rendered) {
  15787. return
  15788. }
  15789. a = true;
  15790. Ext.Function.defer(function() {
  15791. this.el.select(this.eventSelector)
  15792. .setOpacity(0.15)
  15793. }, 10 * 60 * 1000, this);
  15794. var c = this.el.parent().createChild({
  15795. tag : "a",
  15796. href : "http://www.bryntum.com/store",
  15797. title : "Click here to purchase a license",
  15798. 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;"
  15799. });
  15800. Ext.Function.defer(c.fadeOut, 10000, c);
  15801. try {
  15802. if (!Ext.util.Cookies.get("bmeval")) {
  15803. Ext.util.Cookies.set("bmeval",
  15804. new Date().getTime(), Ext.Date.add(
  15805. new Date(), Ext.Date.YEAR, 2))
  15806. } else {
  15807. var g = Ext.util.Cookies.get("bmeval"), d = new Date(parseInt(
  15808. g, 10));
  15809. if (Ext.Date.add(d, Ext.Date.DAY, 45) < new Date()) {
  15810. this.el.select(this.eventSelector).hide();
  15811. this.el.mask("Trial Period Expired!").setStyle(
  15812. "z-index", 10000);
  15813. this.refresh = Ext.emptyFn
  15814. }
  15815. }
  15816. } catch (f) {
  15817. }
  15818. }
  15819. })
  15820. }
  15821. }
  15822. });*/
  15823. Ext.data.Connection.override({
  15824. parseStatus : function(b) {
  15825. var a = this.callOverridden(arguments);
  15826. if (b === 0) {
  15827. a.success = true
  15828. }
  15829. return a
  15830. }
  15831. });