2020-08-14 13:36:36 +02:00
/ * !
* Vue . js v1 . 0.27
* ( c ) 2016 Evan You
* Released under the MIT License .
* /
! function ( t , e ) { "object" == typeof exports && "undefined" != typeof module ? module . exports = e ( ) : "function" == typeof define && define . amd ? define ( e ) : t . Vue = e ( ) } ( this , function ( ) { "use strict" ; function t ( e , n , r ) { if ( i ( e , n ) ) return void ( e [ n ] = r ) ; if ( e . _isVue ) return void t ( e . _data , n , r ) ; var s = e . _ _ob _ _ ; if ( ! s ) return void ( e [ n ] = r ) ; if ( s . convert ( n , r ) , s . dep . notify ( ) , s . vms ) for ( var o = s . vms . length ; o -- ; ) { var a = s . vms [ o ] ; a . _proxy ( n ) , a . _digest ( ) } return r } function e ( t , e ) { if ( i ( t , e ) ) { delete t [ e ] ; var n = t . _ _ob _ _ ; if ( ! n ) return void ( t . _isVue && ( delete t . _data [ e ] , t . _digest ( ) ) ) ; if ( n . dep . notify ( ) , n . vms ) for ( var r = n . vms . length ; r -- ; ) { var s = n . vms [ r ] ; s . _unproxy ( e ) , s . _digest ( ) } } } function i ( t , e ) { return Ii . call ( t , e ) } function n ( t ) { return Mi . test ( t ) } function r ( t ) { var e = ( t + "" ) . charCodeAt ( 0 ) ; return 36 === e || 95 === e } function s ( t ) { return null == t ? "" : t . toString ( ) } function o ( t ) { if ( "string" != typeof t ) return t ; var e = Number ( t ) ; return isNaN ( e ) ? t : e } function a ( t ) { return "true" === t || "false" !== t && t } function h ( t ) { var e = t . charCodeAt ( 0 ) , i = t . charCodeAt ( t . length - 1 ) ; return e !== i || 34 !== e && 39 !== e ? t : t . slice ( 1 , - 1 ) } function l ( t ) { return t . replace ( Vi , c ) } function c ( t , e ) { return e ? e . toUpperCase ( ) : "" } function u ( t ) { return t . replace ( Wi , "$1-$2" ) . replace ( Wi , "$1-$2" ) . toLowerCase ( ) } function f ( t ) { return t . replace ( Bi , c ) } function p ( t , e ) { return function ( i ) { var n = arguments . length ; return n ? n > 1 ? t . apply ( e , arguments ) : t . call ( e , i ) : t . call ( e ) } } function d ( t , e ) { e = e || 0 ; for ( var i = t . length - e , n = new Array ( i ) ; i -- ; ) n [ i ] = t [ i + e ] ; return n } function v ( t , e ) { for ( var i = Object . keys ( e ) , n = i . length ; n -- ; ) t [ i [ n ] ] = e [ i [ n ] ] ; return t } function m ( t ) { return null !== t && "object" == typeof t } function g ( t ) { return zi . call ( t ) === Ui } function _ ( t , e , i , n ) { Object . defineProperty ( t , e , { value : i , enumerable : ! ! n , writable : ! 0 , configurable : ! 0 } ) } function y ( t , e ) { var i , n , r , s , o , a = function a ( ) { var h = Date . now ( ) - s ; h < e && h >= 0 ? i = setTimeout ( a , e - h ) : ( i = null , o = t . apply ( r , n ) , i || ( r = n = null ) ) } ; return function ( ) { return r = this , n = arguments , s = Date . now ( ) , i || ( i = setTimeout ( a , e ) ) , o } } function b ( t , e ) { for ( var i = t . length ; i -- ; ) if ( t [ i ] === e ) return i ; return - 1 } function w ( t ) { var e = function e ( ) { if ( ! e . cancelled ) return t . apply ( this , arguments ) } ; return e . cancel = function ( ) { e . cancelled = ! 0 } , e } function C ( t , e ) { return t == e || ! ( ! m ( t ) || ! m ( e ) ) && JSON . stringify ( t ) === JSON . stringify ( e ) } function $ ( t ) { this . size = 0 , this . limit = t , this . head = this . tail = void 0 , this . _keymap = Object . create ( null ) } function k ( ) { return cn . charCodeAt ( pn + 1 ) } function x ( ) { return cn . charCodeAt ( ++ pn ) } function A ( ) { return pn >= fn } function O ( ) { for ( ; k ( ) === An ; ) x ( ) } function T ( t ) { return t === Cn || t === $n } function N ( t ) { return On [ t ] } function j ( t , e ) { return Tn [ t ] === e } function E ( ) { for ( var t , e = x ( ) ; ! A ( ) ; ) if ( t = x ( ) , t === xn ) x ( ) ; else if ( t === e ) break } function F ( t ) { for ( var e = 0 , i = t ; ! A ( ) ; ) if ( t = k ( ) , T ( t ) ) E ( ) ; else if ( i === t && e ++ , j ( i , t ) && e -- , x ( ) , 0 === e ) break } function S ( ) { for ( var t = pn ; ! A ( ) ; ) if ( dn = k ( ) , T ( dn ) ) E ( ) ; else if ( N ( dn ) ) F ( dn ) ; else if ( dn === kn ) { if ( x ( ) , dn = k ( ) , dn !== kn ) { vn !== _n && vn !== wn || ( vn = yn ) ; break } x ( ) } else { if ( dn === An && ( vn === bn || vn === wn ) ) { O ( ) ; break } vn === yn && ( vn = bn ) , x ( ) } return cn . slice ( t + 1 , pn ) || null } function D ( ) { for ( var t = [ ] ; ! A ( ) ; ) t . push ( P ( ) ) ; return t } function P ( ) { var t , e = { } ; return vn = yn , e . name = S ( ) . trim ( ) , vn = wn , t = R ( ) , t . length && ( e . args = t ) , e } function R ( ) { for ( var t = [ ] ; ! A ( ) && vn !== yn ; ) { var e = S ( ) ; if ( ! e ) break ; t . push ( L ( e ) ) } return t } function L ( t ) { if ( gn . test ( t ) ) return { value : o ( t ) , dynamic : ! 1 } ; var e = h ( t ) , i = e === t ; return { value : i ? t : e , dynamic : i } } function H ( t ) { var e = mn . get ( t ) ; if ( e ) return e ; cn = t , un = { } , fn = cn . length , pn = - 1 , dn = "" , vn = _n ; var i ; return cn . indexOf ( "|" ) < 0 ? un . expression = cn . trim ( ) : ( un . expression = S ( ) . trim ( ) , i = D ( ) , i . length && ( un . filters = i ) ) , mn . put ( t , un ) , un } function I ( t ) { return t . replace ( jn , "\\$&" ) } function M ( ) { var t = I ( Hn . delimiters [ 0 ] ) , e = I ( Hn . delimiters [ 1 ] ) , i = I ( Hn . unsafeDelimiters [ 0 ] ) , n = I ( Hn . unsafeDelimiters [ 1 ] ) ; Fn = new RegExp ( i + "((?:.|\\n)+?)" + n + "|" + t + "((?:.|\\n)+?)" + e , "g" ) , Sn = new RegExp ( "^" + i + "((?:.|\\n)+?)" + n + "$" ) , En = new $ ( 1e3 ) } function V ( t ) { En || M ( ) ; var e = En . get ( t ) ; if ( e ) return e ; if ( ! Fn . test ( t ) ) return null ; for ( var i , n , r , s , o , a , h = [ ] , l = Fn . lastIndex = 0 ; i = Fn . exec ( t ) ; ) n = i . index , n > l && h . push ( { value : t . slice ( l , n ) } ) , r = Sn . test ( i [ 0 ] ) , s = r ? i [ 1 ] : i [ 2 ] , o = s . charCodeAt ( 0 ) , a = 42 === o , s = a ? s . slice ( 1 ) : s , h . push ( { tag : ! 0 , value : s . trim ( ) , html : r , oneTime : a } ) , l = n + i
e . replace && rt ( i , t ) , this . _isCompiled = ! 0 , this . _callHook ( "compiled" ) } } , t . prototype . _initElement = function ( t ) { yt ( t ) ? ( this . _isFragment = ! 0 , this . $el = this . _fragmentStart = t . firstChild , this . _fragmentEnd = t . lastChild , 3 === this . _fragmentStart . nodeType && ( this . _fragmentStart . data = this . _fragmentEnd . data = "" ) , this . _fragment = t ) : this . $el = t , this . $el . _ _vue _ _ = this , this . _callHook ( "beforeCompile" ) } , t . prototype . _bindDir = function ( t , e , i , n , r ) { this . _directives . push ( new Ai ( t , this , e , i , n , r ) ) } , t . prototype . _destroy = function ( t , e ) { if ( this . _isBeingDestroyed ) return void ( e || this . _cleanup ( ) ) ; var i , n , r = this , s = function ( ) { ! i || n || e || r . _cleanup ( ) } ; t && this . $el && ( n = ! 0 , this . $remove ( function ( ) { n = ! 1 , s ( ) } ) ) , this . _callHook ( "beforeDestroy" ) , this . _isBeingDestroyed = ! 0 ; var o , a = this . $parent ; for ( a && ! a . _isBeingDestroyed && ( a . $children . $remove ( this ) , this . _updateRef ( ! 0 ) ) , o = this . $children . length ; o -- ; ) this . $children [ o ] . $destroy ( ) ; for ( this . _propsUnlinkFn && this . _propsUnlinkFn ( ) , this . _unlinkFn && this . _unlinkFn ( ) , o = this . _watchers . length ; o -- ; ) this . _watchers [ o ] . teardown ( ) ; this . $el && ( this . $el . _ _vue _ _ = null ) , i = ! 0 , s ( ) } , t . prototype . _cleanup = function ( ) { this . _isDestroyed || ( this . _frag && this . _frag . children . $remove ( this ) , this . _data && this . _data . _ _ob _ _ && this . _data . _ _ob _ _ . removeVm ( this ) , this . $el = this . $parent = this . $root = this . $children = this . _watchers = this . _context = this . _scope = this . _directives = null , this . _isDestroyed = ! 0 , this . _callHook ( "destroyed" ) , this . $off ( ) ) } } function Ti ( t ) { t . prototype . _applyFilters = function ( t , e , i , n ) { var r , s , o , a , h , l , c , u , f ; for ( l = 0 , c = i . length ; l < c ; l ++ ) if ( r = i [ n ? c - l - 1 : l ] , s = jt ( this . $options , "filters" , r . name , ! 0 ) , s && ( s = n ? s . write : s . read || s , "function" == typeof s ) ) { if ( o = n ? [ t , e ] : [ t ] , h = n ? 2 : 1 , r . args ) for ( u = 0 , f = r . args . length ; u < f ; u ++ ) a = r . args [ u ] , o [ u + h ] = a . dynamic ? this . $get ( a . value ) : a . value ; t = s . apply ( this , o ) } return t } , t . prototype . _resolveComponent = function ( e , i ) { var n ; if ( n = "function" == typeof e ? e : jt ( this . $options , "components" , e , ! 0 ) ) if ( n . options ) i ( n ) ; else if ( n . resolved ) i ( n . resolved ) ; else if ( n . requested ) n . pendingCallbacks . push ( i ) ; else { n . requested = ! 0 ; var r = n . pendingCallbacks = [ i ] ; n . call ( this , function ( e ) { g ( e ) && ( e = t . extend ( e ) ) , n . resolved = e ; for ( var i = 0 , s = r . length ; i < s ; i ++ ) r [ i ] ( e ) } , function ( t ) { } ) } } } function Ni ( t ) { function i ( t ) { return JSON . parse ( JSON . stringify ( t ) ) } t . prototype . $get = function ( t , e ) { var i = Yt ( t ) ; if ( i ) { if ( e ) { var n = this ; return function ( ) { n . $arguments = d ( arguments ) ; var t = i . get . call ( n , n ) ; return n . $arguments = null , t } } try { return i . get . call ( this , this ) } catch ( t ) { } } } , t . prototype . $set = function ( t , e ) { var i = Yt ( t , ! 0 ) ; i && i . set && i . set . call ( this , this , e ) } , t . prototype . $delete = function ( t ) { e ( this . _data , t ) } , t . prototype . $watch = function ( t , e , i ) { var n , r = this ; "string" == typeof t && ( n = H ( t ) , t = n . expression ) ; var s = new re ( r , t , e , { deep : i && i . deep , sync : i && i . sync , filters : n && n . filters , user : ! i || i . user !== ! 1 } ) ; return i && i . immediate && e . call ( r , s . value ) , function ( ) { s . teardown ( ) } } , t . prototype . $eval = function ( t , e ) { if ( ao . test ( t ) ) { var i = H ( t ) , n = this . $get ( i . expression , e ) ; return i . filters ? this . _applyFilters ( n , null , i . filters ) : n } return this . $get ( t , e ) } , t . prototype . $interpolate = function ( t ) { var e = V ( t ) , i = this ; return e ? 1 === e . length ? i . $eval ( e [ 0 ] . value ) + "" : e . map ( function ( t ) { return t . tag ? i . $eval ( t . value ) : t . value } ) . join ( "" ) : t } , t . prototype . $log = function ( t ) { var e = t ? Bt ( this . _data , t ) : this . _data ; if ( e && ( e = i ( e ) ) , ! t ) { var n ; for ( n in this . $options . computed ) e [ n ] = i ( this [ n ] ) ; if ( this . _props ) for ( n in this . _props ) e [ n ] = i ( this [ n ] ) } console . log ( e ) } } function ji ( t ) { function e ( t , e , n , r , s , o ) { e = i ( e ) ; var a = ! Z ( e ) , h = r === ! 1 || a ? s : o , l = ! a && ! t . _isAttached && ! Z ( t . $el ) ; return t . _isFragment ? ( gt ( t . _fragmentStart , t . _fragmentEnd , function ( i ) { h ( i , e , t ) } ) , n && n ( ) ) : h ( t . $el , e , t , n ) , l && t . _callHook ( "attached" ) , t } function i ( t ) { return "string" == typeof t ? document . querySelector ( t ) : t } function n ( t , e , i , n ) { e . appendChild ( t ) , n && n ( ) } function r ( t , e , i , n ) { tt ( t , e ) , n && n ( ) } function s ( t , e , i ) { it ( t ) , i && i ( ) } t . prototype . $nextTick = function ( t ) { an ( t , this ) } , t . prototype . $appendTo = function ( t , i , r ) { return e ( this , t , i , r , n , U ) } , t . prototype . $prependTo = function ( t , e , n ) { return t = i ( t ) , t . hasChildNodes ( ) ? this . $before ( t . firstChild , e , n ) : this . $appendTo ( t , e , n ) , this } , t . prototype . $before = function ( t , i , n ) { return e ( this , t , i , n , r , q ) } , t . prototype . $after = function ( t , e , n ) { return t = i ( t
for ( e in t ) i = t [ e ] , i !== n [ e ] && ( n [ e ] = i , this . handleSingle ( e , i ) ) } , handleSingle : function ( t , e ) { if ( t = Te ( t ) ) if ( null != e && ( e += "" ) , e ) { var i = _s . test ( e ) ? "important" : "" ; i ? ( e = e . replace ( _s , "" ) . trim ( ) , this . el . style . setProperty ( t . kebab , e , i ) ) : this . el . style [ t . camel ] = e } else this . el . style [ t . camel ] = "" } } , Cs = "http://www.w3.org/1999/xlink" , $s = /^xlink:/ , ks = /^v-|^:|^@|^(?:is|transition|transition-mode|debounce|track-by|stagger|enter-stagger|leave-stagger)$/ , xs = /^(?:value|checked|selected|muted)$/ , As = /^(?:draggable|contenteditable|spellcheck)$/ , Os = { value : "_value" , "true-value" : "_trueValue" , "false-value" : "_falseValue" } , Ts = { priority : Zr , bind : function ( ) { var t = this . arg , e = this . el . tagName ; t || ( this . deep = ! 0 ) ; var i = this . descriptor , n = i . interp ; n && ( i . hasOneTime && ( this . expression = W ( n , this . _scope || this . vm ) ) , ( ks . test ( t ) || "name" === t && ( "PARTIAL" === e || "SLOT" === e ) ) && ( this . el . removeAttribute ( t ) , this . invalid = ! 0 ) ) } , update : function ( t ) { if ( ! this . invalid ) { var e = this . arg ; this . arg ? this . handleSingle ( e , t ) : this . handleObject ( t || { } ) } } , handleObject : ws . handleObject , handleSingle : function ( t , e ) { var i = this . el , n = this . descriptor . interp ; if ( this . modifiers . camel && ( t = l ( t ) ) , ! n && xs . test ( t ) && t in i ) { var r = "value" === t && null == e ? "" : e ; i [ t ] !== r && ( i [ t ] = r ) } var s = Os [ t ] ; if ( ! n && s ) { i [ s ] = e ; var o = i . _ _v _model ; o && o . listener ( ) } return "value" === t && "TEXTAREA" === i . tagName ? void i . removeAttribute ( t ) : void ( As . test ( t ) ? i . setAttribute ( t , e ? "true" : "false" ) : null != e && e !== ! 1 ? "class" === t ? ( i . _ _v _trans && ( e += " " + i . _ _v _trans . id + "-transition" ) , ht ( i , e ) ) : $s . test ( t ) ? i . setAttributeNS ( Cs , t , e === ! 0 ? "" : e ) : i . setAttribute ( t , e === ! 0 ? "" : e ) : i . removeAttribute ( t ) ) } } , Ns = { priority : Yr , bind : function ( ) { if ( this . arg ) { var t = this . id = l ( this . arg ) , e = ( this . _scope || this . vm ) . $els ; i ( e , t ) ? e [ t ] = this . el : Lt ( e , t , this . el ) } } , unbind : function ( ) { var t = ( this . _scope || this . vm ) . $els ; t [ this . id ] === this . el && ( t [ this . id ] = null ) } } , js = { bind : function ( ) { } } , Es = { bind : function ( ) { var t = this . el ; this . vm . $once ( "pre-hook:compiled" , function ( ) { t . removeAttribute ( "v-cloak" ) } ) } } , Fs = { text : Rr , html : qr , for : ss , if : os , show : as , model : ps , on : vs , bind : Ts , el : Ns , ref : js , cloak : Es } , Ss = { deep : ! 0 , update : function ( t ) { t ? "string" == typeof t ? this . setClass ( t . trim ( ) . split ( /\s+/ ) ) : this . setClass ( je ( t ) ) : this . cleanup ( ) } , setClass : function ( t ) { this . cleanup ( t ) ; for ( var e = 0 , i = t . length ; e < i ; e ++ ) { var n = t [ e ] ; n && Ee ( this . el , n , lt ) } this . prevKeys = t } , cleanup : function ( t ) { var e = this . prevKeys ; if ( e ) for ( var i = e . length ; i -- ; ) { var n = e [ i ] ; ( ! t || t . indexOf ( n ) < 0 ) && Ee ( this . el , n , ct ) } } } , Ds = { priority : Kr , params : [ "keep-alive" , "transition-mode" , "inline-template" ] , bind : function ( ) { this . el . _ _vue _ _ || ( this . keepAlive = this . params . keepAlive , this . keepAlive && ( this . cache = { } ) , this . params . inlineTemplate && ( this . inlineTemplate = ut ( this . el , ! 0 ) ) , this . pendingComponentCb = this . Component = null , this . pendingRemovals = 0 , this . pendingRemovalCb = null , this . anchor = vt ( "v-component" ) , rt ( this . el , this . anchor ) , this . el . removeAttribute ( "is" ) , this . el . removeAttribute ( ":is" ) , this . descriptor . ref && this . el . removeAttribute ( "v-ref:" + u ( this . descriptor . ref ) ) , this . literal && this . setComponent ( this . expression ) ) } , update : function ( t ) { this . literal || this . setComponent ( t ) } , setComponent : function ( t , e ) { if ( this . invalidatePending ( ) , t ) { var i = this ; this . resolveComponent ( t , function ( ) { i . mountComponent ( e ) } ) } else this . unbuild ( ! 0 ) , this . remove ( this . childVM , e ) , this . childVM = null } , resolveComponent : function ( t , e ) { var i = this ; this . pendingComponentCb = w ( function ( n ) { i . ComponentName = n . options . name || ( "string" == typeof t ? t : null ) , i . Component = n , e ( ) } ) , this . vm . _resolveComponent ( t , this . pendingComponentCb ) } , mountComponent : function ( t ) { this . unbuild ( ! 0 ) ; var e = this , i = this . Component . options . activate , n = this . getCached ( ) , r = this . build ( ) ; i && ! n ? ( this . waitingFor = r , Fe ( i , r , function ( ) { e . waitingFor === r && ( e . waitingFor = null , e . transition ( r , t ) ) } ) ) : ( n && r . _updateRef ( ) , this . transition ( r , t ) ) } , invalidatePending : function ( ) { this . pendingComponentCb && ( this . pendingComponentCb . cancel ( ) , this . pendingComponentCb = null ) } , build : function ( t ) { var e = this . getCached ( ) ; if ( e ) return e ; if ( this . Component ) { var i = { name : this . ComponentName , el : le ( this . el ) , template : this . inlineTemplate , parent : this . _host || this . vm , _linkerCachable : ! this . inlineTemplate , _ref : this . descriptor . ref , _asComponent : ! 0 , _isRouterView : this . _isRouterV
//# sourceMappingURL=vue.min.js.map
/ * *
* vue - resource v0 . 7.0
* https : //github.com/vuejs/vue-resource
* Released under the MIT License .
* /
! function ( t , e ) { "object" == typeof exports && "object" == typeof module ? module . exports = e ( ) : "function" == typeof define && define . amd ? define ( [ ] , e ) : "object" == typeof exports ? exports . VueResource = e ( ) : t . VueResource = e ( ) } ( this , function ( ) { return function ( t ) { function e ( r ) { if ( n [ r ] ) return n [ r ] . exports ; var o = n [ r ] = { exports : { } , id : r , loaded : ! 1 } ; return t [ r ] . call ( o . exports , o , o . exports , e ) , o . loaded = ! 0 , o . exports } var n = { } ; return e . m = t , e . c = n , e . p = "" , e ( 0 ) } ( [ function ( t , e , n ) { function r ( t ) { var e = n ( 1 ) ; e . config = t . config , e . warning = t . util . warn , e . nextTick = t . util . nextTick , t . url = n ( 2 ) , t . http = n ( 8 ) , t . resource = n ( 23 ) , t . Promise = n ( 10 ) , Object . defineProperties ( t . prototype , { $url : { get : function ( ) { return e . options ( t . url , this , this . $options . url ) } } , $http : { get : function ( ) { return e . options ( t . http , this , this . $options . http ) } } , $resource : { get : function ( ) { return t . resource . bind ( this ) } } , $promise : { get : function ( ) { return function ( e ) { return new t . Promise ( e , this ) } . bind ( this ) } } } ) } window . Vue && Vue . use ( r ) , t . exports = r } , function ( t , e ) { function n ( t , e , o ) { for ( var i in e ) o && ( r . isPlainObject ( e [ i ] ) || r . isArray ( e [ i ] ) ) ? ( r . isPlainObject ( e [ i ] ) && ! r . isPlainObject ( t [ i ] ) && ( t [ i ] = { } ) , r . isArray ( e [ i ] ) && ! r . isArray ( t [ i ] ) && ( t [ i ] = [ ] ) , n ( t [ i ] , e [ i ] , o ) ) : void 0 !== e [ i ] && ( t [ i ] = e [ i ] ) } var r = e , o = [ ] , i = window . console ; r . warn = function ( t ) { i && r . warning && ( ! r . config . silent || r . config . debug ) && i . warn ( "[VueResource warn]: " + t ) } , r . error = function ( t ) { i && i . error ( t ) } , r . trim = function ( t ) { return t . replace ( /^\s*|\s*$/g , "" ) } , r . toLower = function ( t ) { return t ? t . toLowerCase ( ) : "" } , r . isArray = Array . isArray , r . isString = function ( t ) { return "string" == typeof t } , r . isFunction = function ( t ) { return "function" == typeof t } , r . isObject = function ( t ) { return null !== t && "object" == typeof t } , r . isPlainObject = function ( t ) { return r . isObject ( t ) && Object . getPrototypeOf ( t ) == Object . prototype } , r . options = function ( t , e , n ) { return n = n || { } , r . isFunction ( n ) && ( n = n . call ( e ) ) , r . merge ( t . bind ( { $vm : e , $options : n } ) , t , { $options : n } ) } , r . each = function ( t , e ) { var n , o ; if ( "number" == typeof t . length ) for ( n = 0 ; n < t . length ; n ++ ) e . call ( t [ n ] , t [ n ] , n ) ; else if ( r . isObject ( t ) ) for ( o in t ) t . hasOwnProperty ( o ) && e . call ( t [ o ] , t [ o ] , o ) ; return t } , r . defaults = function ( t , e ) { for ( var n in e ) void 0 === t [ n ] && ( t [ n ] = e [ n ] ) ; return t } , r . extend = function ( t ) { var e = o . slice . call ( arguments , 1 ) ; return e . forEach ( function ( e ) { n ( t , e ) } ) , t } , r . merge = function ( t ) { var e = o . slice . call ( arguments , 1 ) ; return e . forEach ( function ( e ) { n ( t , e , ! 0 ) } ) , t } } , function ( t , e , n ) { function r ( t , e ) { var n , i = t ; return s . isString ( t ) && ( i = { url : t , params : e } ) , i = s . merge ( { } , r . options , this . $options , i ) , r . transforms . forEach ( function ( t ) { n = o ( t , n , this . $vm ) } , this ) , n ( i ) } function o ( t , e , n ) { return function ( r ) { return t . call ( n , r , e ) } } function i ( t , e , n ) { var r , o = s . isArray ( e ) , a = s . isPlainObject ( e ) ; s . each ( e , function ( e , u ) { r = s . isObject ( e ) || s . isArray ( e ) , n && ( u = n + "[" + ( a || r ? u : "" ) + "]" ) , ! n && o ? t . add ( e . name , e . value ) : r ? i ( t , e , u ) : t . add ( u , e ) } ) } var s = n ( 1 ) , a = document . documentMode , u = document . createElement ( "a" ) ; r . options = { url : "" , root : null , params : { } } , r . transforms = [ n ( 3 ) , n ( 5 ) , n ( 6 ) , n ( 7 ) ] , r . params = function ( t ) { var e = [ ] , n = encodeURIComponent ; return e . add = function ( t , e ) { s . isFunction ( e ) && ( e = e ( ) ) , null === e && ( e = "" ) , this . push ( n ( t ) + "=" + n ( e ) ) } , i ( e , t ) , e . join ( "&" ) . replace ( /%20/g , "+" ) } , r . parse = function ( t ) { return a && ( u . href = t , t = u . href ) , u . href = t , { href : u . href , protocol : u . protocol ? u . protocol . replace ( /:$/ , "" ) : "" , port : u . port , host : u . host , hostname : u . hostname , pathname : "/" === u . pathname . charAt ( 0 ) ? u . pathname : "/" + u . pathname , search : u . search ? u . search . replace ( /^\?/ , "" ) : "" , hash : u . hash ? u . hash . replace ( /^#/ , "" ) : "" } } , t . exports = s . url = r } , function ( t , e , n ) { var r = n ( 4 ) ; t . exports = function ( t ) { var e = [ ] , n = r . expand ( t . url , t . params , e ) ; return e . forEach ( function ( e ) { delete t . params [ e ] } ) , n } } , function ( t , e ) { e . expand = function ( t , e , n ) { var r = this . parse ( t ) , o = r . expand ( e ) ; return n && n . push . apply ( n , r . vars ) , o } , e . parse = function ( t ) { var n = [ "+" , "#" , "." , "/" , ";" , "?" , "&" ] , r = [ ] ; return { vars : r , expand : function ( o ) { return t . replace ( /\{([^\{\}]+)\}|([^\{\}]+)/g , function ( t , i , s ) { if ( i ) { var a = null , u = [ ] ; if ( - 1 !== n . indexOf ( i . charAt ( 0 ) ) && ( a = i . charAt ( 0 ) , i = i . substr ( 1 ) ) , i . split ( /,/g ) . forEach ( function ( t ) { var n = /([^:\*]*)(?::(\d+)|(\*))?/ . exec ( t ) ; u . push . apply ( u , e . getValues ( o , a , n [ 1 ] , n [ 2 ] || n [ 3 ] ) ) , r . push ( n [ 1 ] ) } ) , a && "+" !== a ) { var c = "," ; return "?" === a ? c = "&" : "#" !
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
DOCUMENT READY
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
var tabela = null ;
var anketa _id = 0 ;
$ ( document ) . ready ( function ( ) {
// pridobimo ID ankete, ko je dokument naložen
anketa _id = $ ( '#srv_meta_anketa_id' ) . val ( ) ;
//vklopljeno iskanje za vse select box elemente
$ ( '.h-selected select.hierarhija-select' ) . chosen ( ) ;
$ ( '.h-selected.hierarhija-select' ) . chosen ( ) ;
//Vklopi nice input file
$ ( "input[type=file]" ) . nicefileinput ( {
label : 'Poišči datoteko...'
} ) ;
//Data Tables konfiguracija za vpis šifrantov
if ( $ ( '#vpis-sifrantov-admin-tabela' ) . length > 0 ) {
tabela = $ ( '#vpis-sifrantov-admin-tabela' ) . DataTable ( {
"processing" : true ,
"lengthMenu" : [ [ 20 , 40 , 100 , 200 , - 1 ] , [ 20 , 40 , 100 , 200 , "vse" ] ] ,
"ajax" : 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=get-datatables-data' ,
"drawCallback" : function ( settings ) {
if ( tabela . page . info ( ) . recordsTotal == 0 ) {
$ ( '#div-datatables' ) . hide ( ) ;
$ ( '#hierarhija-jstree-ime' ) . hide ( ) ;
$ ( '#admin_hierarhija_jstree' ) . hide ( ) ;
} else {
$ ( '#div-datatables' ) . show ( ) ;
$ ( '#hierarhija-jstree-ime' ) . show ( ) ;
$ ( '#admin_hierarhija_jstree' ) . show ( ) ;
}
} ,
"createdRow" : function ( row , data , rowIndex ) {
// gremo po vseh td elementih
$ . each ( $ ( 'td' , row ) , function ( colIndex ) {
// SQL query nam vrne objek, ki ga uporabimo za datatables vpis vrstice
if ( data [ colIndex ] && data [ colIndex ] . label ) {
// Vsaka celica ima id strukture, ki je potreben za urejanje uporabbnikov za posamezno vrstico
$ ( this ) . attr ( 'data-struktura' , data [ colIndex ] . id ) ;
// Vsaka celica ima številko nivoja - level
$ ( this ) . attr ( 'data-level' , data [ colIndex ] . level ) ;
// Prikaz podatkov
$ ( this ) . html ( data [ colIndex ] . label ) ;
}
} ) ;
} ,
"language" : {
"url" : "modules/mod_hierarhija/js/vendor/datatables-slovenian.json"
}
} ) ;
}
// datatables za prikaz že vpisanih šifrantov
if ( $ ( '#pregled-sifrantov-admin-tabela' ) . length > 0 ) {
$ ( '#pregled-sifrantov-admin-tabela' ) . DataTable ( {
ajax : 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=get-datatables-data&m=1&p=1' ,
"language" : {
"url" : "modules/mod_hierarhija/js/vendor/datatables-slovenian.json"
}
} ) ;
}
// Klik na ikono za komentar
$ ( '.surveycomment' ) . on ( 'click' , function ( ) {
dodajKomentar ( ) ;
} ) ;
// Klik na ikono za upload logo - naloži logotip
$ ( '.logo-upload' ) . on ( 'click' , function ( ) {
uploadLogo ( ) ;
} ) ;
// Skrivamo filtrov in vprašanj pri analizah
$ ( '.znak' ) . on ( 'click' , function ( e ) {
var razred = e . currentTarget . className ;
if ( razred == 'znak minus' ) {
$ ( '#div_means_dropdowns' ) . animate ( 'slow' ) . hide ( ) ;
$ ( '.minus' ) . hide ( ) ;
$ ( '.plus' ) . show ( ) ;
} else {
$ ( '#div_means_dropdowns' ) . animate ( 'slow' ) . show ( ) ;
$ ( '.plus' ) . hide ( ) ;
$ ( '.minus' ) . show ( ) ;
}
} ) ;
// Skrijemo error, ki se je pojavil
$ ( '.error-display' ) . delay ( 10000 ) . fadeOut ( 'slow' ) ;
} ) ;
// uredi vrstico
// function urediVrsticoHierarhije(id) {
// var anketa_id = $('#anketa_id').val();
// var el = $('.btn-urejanje-hierarhije[data-id="' + id + '"]').parent().siblings().last();
// var text = el.html().split(" - ");
//
// // pridobi vse uporabnike, ki so dodani na trenutno hierarhijo
// var opcije = [];
// // $.post("ajax.php?anketa=" + anketa_id + "&t=hierarhija-ajax&a=gradnja-hierarhije&m=get-uporabniki", {
// // id: id
// // }).success(function (data) {
// // if (data == 0)
// // return opcije;
// //
// // // vse emaili dodamo med opcije in polje, ki ga kasneje združimo v string
// // $.each(JSON.parse(data), function (key, val) {
// // opcije.push('<option value="' + key + '" ' + val.selected + '>' + val.uporabnik + '</option>');
// // });
// //
// // el.html('Izbira: <b>' + text[0] + '</b><br/>Uporabniki:<select id="select2-email-' + id + '" multiple>' + opcije.join("") + '</seclect>');
// // $('.btn-urejanje-hierarhije[data-id="' + id + '"]').text('Vpiši').attr('onclick', 'vpisiVrsticoHierarhije(' + id + ')');
// //
// // $('#select2-email-' + id).select2();
// // });
//
//
// }
var vrsticaAktivnoUrejanje = {
html : '' ,
id : 0 ,
izbris : 0
} ;
function urediVrsticoHierarhije ( id ) {
// V kolikor je ponovno kliknil na urejanje, potem samo vrnemo in na ponovno neurejanje
if ( vrsticaAktivnoUrejanje . id == id ) {
// Vpišemo stare podatke vrstice, brez urejanja
$ ( '#vpis-sifrantov-admin-tabela .aktivno-urejanje' ) . html ( vrsticaAktivnoUrejanje . html ) ;
// Odstranimo razrede
$ ( '#vpis-sifrantov-admin-tabela .h-uporabnik' ) . remove ( ) ;
$ ( '#vpis-sifrantov-admin-tabela .aktivno-urejanje' ) . removeClass ( ) ;
// če je bil uporabnik izbrisan potem osvežimo celotno tabelo
if ( vrsticaAktivnoUrejanje . izbris == 1 )
tabela . ajax . reload ( null , false ) ;
// Ponastavimo globalno spremenljivko
return vrsticaAktivnoUrejanje = {
html : '' ,
id : 0 ,
izbris : 0
} ;
}
// V kolikor obstaja podatek cele vrstice od prej in je aktivni razred . aktivno-urejanje, potem vsebino prekopiramo
if ( vrsticaAktivnoUrejanje . html . length > 0 && $ ( '#vpis-sifrantov-admin-tabela .aktivno-urejanje' ) . length > 0 )
$ ( '#vpis-sifrantov-admin-tabela .aktivno-urejanje' ) . html ( vrsticaAktivnoUrejanje . html ) ;
// Izbriše ikonice za urejanje uprabnikov in odstrani aktivni razred urejanja
$ ( '#vpis-sifrantov-admin-tabela .h-uporabnik' ) . remove ( ) ;
$ ( '#vpis-sifrantov-admin-tabela .aktivno-urejanje' ) . removeClass ( ) ;
// Vsi elementi, ki vsebujejo ID strukture
var vrstica = $ ( '[data-struktura="' + id + '"]' ) . parent ( ) ;
var stolpci = vrstica . children ( '[data-struktura]' ) ;
// Obarvamo ozadje vrstice
vrstica . addClass ( 'aktivno-urejanje' ) ;
// Celotno vrstico shranimo globalno in tudi id
vrsticaAktivnoUrejanje = {
html : $ ( '#vpis-sifrantov-admin-tabela .aktivno-urejanje' ) . html ( ) ,
id : id
}
// Pridobimo vse TD celice in v vsaki dodamo ikono ter uporabnike za urejati
stolpci . each ( function ( key , val ) {
var self = this ;
var html = $ ( this ) . html ( ) . split ( "<br>" ) ;
var idStrukture = $ ( this ) . attr ( 'data-struktura' ) ;
var uporabnikiHtml = '' ;
// Ajax request, ki pridobi vse uporabnike za vsak nivo posebej
$ . post ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=get-uporabniki' , {
id : idStrukture
} , function ( data ) {
var urejanjeUporabnika = '' ;
// Ikona za pop up, kjer dodajamo še email
urejanjeUporabnika = '<div class="h-uporabnik"><span class="faicon users icon-as_link" onclick="odpriPopup(' + idStrukture + ')"></span></div>' ;
// Če imamo uporabnike na tem nivoju potem jih ustrezno dodamo
if ( data . length > 0 ) {
var podatki = JSON . parse ( data ) ;
// V kolikor imamo uporabnika samo na zadnjem nivoju, potem ni možnosti urejanja, ker ima opcijo briši nivo in uporabnika
if ( $ ( self ) . attr ( 'data-level' ) == podatki . maxLevel ) {
// Opcije za urejanje uporabnika ne potrebujemo na zadnjem nivoju
urejanjeUporabnika = '<div class="h-uporabnik"><span class="icon user-red" onclick="odpriPopup(' + idStrukture + ', 1)"></span></div>' ;
uporabnikiHtml = '<div class="h-uporabnik-prikazi">Uporabnik/i:' +
'<ul>' ;
// Dodamo vse uporabnike, ki so na tem nivoju
if ( podatki . uporabniki ) {
$ . each ( podatki . uporabniki , function ( key , val ) {
uporabnikiHtml += '<li>' + val . uporabnik + '</li>' ;
} ) ;
}
uporabnikiHtml += '</ul></div>' ;
}
else {
// Izpišemo uporabnike in možnost brisanja
uporabnikiHtml = '<div class="h-uporabnik-prikazi">Uporabnik/i:' +
'<ul>' ;
// Dodamo vse uporabnike, ki so na tem nivoju
if ( podatki . uporabniki ) {
$ . each ( podatki . uporabniki , function ( key , val ) {
uporabnikiHtml += '<li>' + val . uporabnik + ' <span class="icon brisi-x" data-id="' + val . id + '" onclick="izbrisiUporabnikaDataTables(' + val . id + ')"></span></li>' ;
} ) ;
}
uporabnikiHtml += '</ul></div>' ;
}
}
$ ( self ) . html ( html [ 0 ] + urejanjeUporabnika + uporabnikiHtml ) ;
} ) ;
} ) ;
}
/ * *
* Prikaži pop - up za uvoz vseh uporabnikov preko tekstovnega polja
* /
function uvoziUporabnike ( ) {
2021-03-15 12:34:26 +01:00
$ ( '#fade' ) . fadeTo ( 'slow' , 1 ) ;
2020-08-14 13:36:36 +02:00
$ ( '#vrednost_edit' ) . html ( '' ) . fadeIn ( 'slow' ) . load ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=import-user&s=get' ) ;
}
function shraniVseVpisaneUporabnike ( ) {
var users = $ ( '#users-email-import' ) . val ( ) ;
if ( users . length < 5 )
return false ;
$ . post ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=import-user&s=post' , {
users : JSON . stringify ( users )
} ) . then ( function ( response ) {
// Pridobimoo uporabnike za select box
var uporabniki = JSON . parse ( response ) ;
gradnjaHierarhijeApp . user . dropdown = uporabniki ;
gradnjaHierarhijeApp . osebe . prikazi = false ;
// Zapremo Pop up
vrednost _cancel ( ) ;
} ) ;
}
/ * *
* Vrstico hierarhije kopiramo v možnost za urejanje uporabnikov , pridobimo zadnji id
* /
function kopirajVrsticoHierarhije ( id ) {
// Poženemo funkcijo v datoteki custom-vue.js
gradnjaHierarhijeApp . pridobiIdSifrantovInUporabnike ( id ) ;
}
// Odpre PopUp in naloži možnost za dodajanje novega uporabnika - textarea
function odpriPopup ( id , last ) {
var last = last || 0 ;
2021-03-15 12:34:26 +01:00
$ ( '#fade' ) . fadeTo ( 'slow' , 1 ) ;
2020-08-14 13:36:36 +02:00
$ ( '#vrednost_edit' ) . html ( '' ) . fadeIn ( 'slow' ) . load ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=uredi-uporabnike-v-strukturi' , {
struktura : id ,
last : last
} ) ;
}
/ * *
* Zamenjamo email uporabnika na zadnjem nivoju z novim emailom - find and replace all
* /
function zamenjajUporabnikaZNovim ( ) {
2021-03-15 12:34:26 +01:00
$ ( '#fade' ) . fadeTo ( 'slow' , 1 ) ;
2020-08-14 13:36:36 +02:00
$ ( '#vrednost_edit' ) . html ( '' ) . fadeIn ( 'slow' ) . load ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=zamenjaj-uporabnika-v-strukturi' ) ;
}
/ * *
* Testno preverimo koliko uporabnikov se bo zamenjalo
* /
function testnoPreveriKolikoUporabnikovBoZamnjenihVStrukturi ( ) {
var findEmail = $ ( '#find-email' ) . val ( ) ;
var replaceEmail = $ ( '#replace-email' ) . val ( ) ;
if ( errorPreverjanjeEmailaZaZamenjavo ( findEmail , replaceEmail ) )
return false ;
$ . post ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=post-st-zamenjav' , {
'find_email' : findEmail
} ) . then ( function ( response ) {
var besedilo = 'Elektronski naslov <b>' + findEmail + '</b> ni bil najden med obstoječimi uporabniki in ga ni mogoče zamenjati.' ;
if ( response > 0 )
besedilo = 'Elektronski naslov <b>' + findEmail + '</b> bo zamenjan z naslovom <b>' + replaceEmail + '</b>.<br />Število zamenjav: <b>' + response + '</b>.' ;
$ ( '#st_zamenjav_uporabnikov' ) . html ( besedilo )
} ) ;
}
function potriZamenjavoUporabnika ( ) {
var findEmail = $ ( '#find-email' ) . val ( ) ;
var replaceEmail = $ ( '#replace-email' ) . val ( ) ;
if ( errorPreverjanjeEmailaZaZamenjavo ( findEmail , replaceEmail ) )
return false ;
$ . post ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=post-zamenjaj-uporabnika-z-novim' , {
'find_email' : findEmail ,
'replace_email' : replaceEmail
} ) . then ( function ( response ) {
tabela . ajax . reload ( null , false ) ;
// zapremo popup
$ ( '#fade' ) . fadeOut ( 'slow' ) ;
$ ( '#vrednost_edit' ) . hide ( ) ;
} ) ;
}
/ * *
* Preverimo , če sta emaila pravilno vpisana tist , ki ga iščemo in tisti , ki je za zamenjavo
* @ param findEmail
* @ param replaceEmail
* @ returns { boolean }
* /
function errorPreverjanjeEmailaZaZamenjavo ( findEmail , replaceEmail ) {
// Preden preverimo odstranimo vse errorje
$ ( '#find-email' ) . siblings ( '.error-label' ) . hide ( ) ;
$ ( '#find-email' ) . removeClass ( 'error' ) ;
$ ( '#replace-email' ) . siblings ( '.error-label' ) . hide ( ) ;
$ ( '#replace-email' ) . removeClass ( 'error' )
if ( ! preveriFormatEmail ( findEmail ) ) {
$ ( '#find-email' ) . siblings ( '.error-label' ) . show ( ) ;
$ ( '#find-email' ) . addClass ( 'error' ) ;
return true ;
}
if ( ! preveriFormatEmail ( replaceEmail ) ) {
$ ( '#replace-email' ) . siblings ( '.error-label' ) . show ( ) ;
$ ( '#replace-email' ) . addClass ( 'error' ) ;
return true ;
}
return false ;
} ;
function preveriFormatEmail ( email ) {
var EMAIL _REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ ;
return EMAIL _REGEX . test ( email ) ;
}
// Shranimo email vpisanih oseb pri urejanju za specifično strukturo
function shrani _email ( id , last ) {
var emails = $ ( '#vpis-email-popup' ) . val ( ) . split ( '\n' ) ;
var last = last || 0 ;
//Loop po vseh vpisanih emailih
$ . each ( emails , function ( key , val ) {
val = val . split ( ',' ) ;
// V kolikor email ni pravilen ga odstranimo iz polja
if ( ! preveriPravilnoVpisanmail ( val [ 0 ] ) ) {
emails . splice ( key , 1 ) ;
} else {
emails [ key ] = val ;
}
} ) ;
// V kolikor ni bil vpisan email, ampak je samo klik na potrdi
if ( typeof emails [ 0 ] == 'undefined' )
return 'error' ;
// Posredujemo samo pravilne emaile
$ . post ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=post-dodatne-uporabnike-k-strukturi' , {
uporabniki : JSON . stringify ( emails ) ,
struktura : id ,
last : last
} , function ( ) {
// osvežimo celoten DataTables
tabela . ajax . reload ( null , false ) ;
// Osvežimo tudi jsTree
jstree _json _data ( anketa _id , 1 ) ;
// zapremo popup
$ ( '#fade' ) . fadeOut ( 'slow' ) ;
$ ( '#vrednost_edit' ) . hide ( ) ;
// celotno strukturo shranimo v string in srv_hierarhija_save
gradnjaHierarhijeApp . shraniUporabnikeNaHierarhijo ( ) ;
} ) ;
}
function preveriPravilnoVpisanmail ( email ) {
var EMAIL _REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ ;
return EMAIL _REGEX . test ( email ) ;
}
// Izbriši uporabnika iz DataTables
function izbrisiUporabnikaDataTables ( id ) {
var str _id = $ ( '[data-id="' + id + '"]' ) . parents ( '[data-struktura]' ) . attr ( 'data-struktura' ) ;
$ . post ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=brisi&m=uporabnika' , {
uporabnik _id : id ,
struktura _id : str _id
} ) . then ( function ( ) {
// Če je uporabnik uspešno izbrisan iz baze, potem tudi izbrišemo iz DataTables
$ ( '[data-id="' + id + '"]' ) . parent ( ) . remove ( ) ;
vrsticaAktivnoUrejanje . izbris = 1 ;
} ) ;
}
// vpiši vrstico v bazo
function vpisiVrsticoHierarhije ( id ) {
var polje = [ ] ;
// vse izbrani ID oseb
$ ( '#select2-email-' + id + ' option:selected' ) . each ( function ( ) {
polje . push ( $ ( this ) . val ( ) ) ;
} ) ;
$ . post ( "ajax.php?anketa=" + anketa _id + "&t=hierarhija-ajax&a=gradnja-hierarhije&m=post-uporabniki" , {
uporabniki : JSON . stringify ( polje ) ,
struktura : id
} , function ( data ) {
// v kolikor ni vpisanega uporabnika potem opozorimo
if ( data == 'uporabnik' ) {
return swal ( {
title : "Opozorilo!" ,
text : "Uporabnik mora biti določen." ,
type : "error" ,
timer : 2000 ,
confirmButtonText : "OK"
} ) ;
}
// osvežimo tabelo, ko smo vpisali podatke
tabela . ajax . reload ( null , false ) ;
jstree _json _data ( anketa _id , 1 ) ;
} ) ;
}
// datatables urejanje, brisanje
function brisiVrsticoHierarhije ( id , osveziTabelo ) {
var osveziTabelo = osveziTabelo || 0 ;
$ . post ( "ajax.php?anketa=" + anketa _id + "&t=hierarhija-ajax&a=brisi_element_v_hierarhiji" , {
id : id
} , function ( p ) {
//Hierarhije je že zgrajena
if ( p == 2 ) {
swal ( {
title : "Hierarhija je zaklenjena!" ,
text : "Brisanje ni več mogoče, ker je hierarhija zaklenjena za urejanje." ,
type : "error" ,
timer : 2000 ,
confirmButtonText : "OK"
} ) ;
//ko javimo napako moramo jstree osvežiti, ker v nasprotnem primeru js še vedno izbriše omenjen element
jstree _json _data ( anketa _id , 1 ) ;
}
//Hierarhije je že zgrajena
if ( p == 'obstaja' ) {
swal ( {
title : "Brisanje ni mogoče!" ,
text : "Ne morete izbrisati omenjenega elementa, ker imate pod njem še izbrano hierarhijo." ,
type : "error" ,
timer : 2000 ,
confirmButtonText : "OK"
} ) ;
//ko javimo napako moramo jstree osvežiti, ker v nasprotnem primeru js še vedno izbriše omenjen element
jstree _json _data ( anketa _id , 1 ) ;
}
tabela . ajax . reload ( null , false ) ;
jstree _json _data ( anketa _id , 1 ) ;
// celotno strukturo shranimo v string in srv_hierarhija_save
gradnjaHierarhijeApp . shraniUporabnikeNaHierarhijo ( ) ;
} ) ;
}
//preverimo, če je obkljukano polje
function preveriCheckDodajEmail ( ) {
if ( $ ( "#dovoli-vpis-emaila" ) . is ( ':checked' ) ) {
$ ( '#vpis-emaila' ) . show ( ) ;
}
else {
$ ( '#vpis-emaila' ) . val ( '' ) . hide ( ) ;
}
}
/ * *
* Opoyorimo v kolikor želi uporabni nadaljevati in ni shraniv emaila trenutnega uporabnika
* /
function opozoriUporabnikaKerNiPotrdilPodatkov ( href ) {
var level = gradnjaHierarhijeApp . podatki . maxLevel ;
// V kolikor imamo uporabnika na zadnjem nivoju
if ( typeof gradnjaHierarhijeApp . osebe . nove [ level ] === 'object' ) {
swal ( {
title : "Opozorilo!" ,
text : "Vnesli ste strukturo za dotičnega uporabnika, vendar omenjene podatke niste shranili. Ali jih želite izbrisati?" ,
type : "error" ,
showCancelButton : true ,
confirmButtonText : "Nadaljuj" ,
cancelButtonText : "Prekliči"
} , function ( dismiss ) {
// V kolikor se uporabnik strinja,ga preusmerimo na naslednji korak
if ( dismiss )
window . location . href = href ;
} ) ;
} else {
window . location . href = href ;
}
}
/ * *
* Shrani komentar k hierarhiji
* /
function shraniKomentar ( ) {
var komentar = $ ( '#hierarhija-komentar' ) . val ( ) ;
var id = $ ( '#hierarhija-komentar' ) . attr ( 'data-id' ) ;
$ . post ( "ajax.php?anketa=" + anketa _id + "&t=hierarhija-ajax&a=komentar-k-hierarhiji&m=post" , {
id : id ,
komentar : komentar
} ) . success ( function ( podatki ) {
if ( podatki == 1 ) {
// zapremo popup
$ ( '#fade' ) . fadeOut ( 'slow' ) ;
$ ( '#vrednost_edit' ) . hide ( ) ;
}
} ) ;
}
/ * *
* Predogled emaila za učitelje in managerje
*
* 1 - email za učitelje na zadnjem nivoju
* 2 - email za managerje na vseh ostalih nivojih
*
* @ param int vrsta - za katero vrsta emaila gre
* /
function previewMail ( vrsta ) {
2021-03-15 12:34:26 +01:00
$ ( '#fade' ) . fadeTo ( 'slow' , 1 ) ;
2020-08-14 13:36:36 +02:00
$ ( '#vrednost_edit' ) . html ( '' ) . fadeIn ( 'slow' ) . load ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=ostalo&m=preview-mail' , {
vrsta : vrsta ,
} ) ;
}
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Hierarhija - jstree , bootstrap select
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
function jstree _json _data ( anketa , refresh ) {
$ . ajax ( {
async : true ,
type : "GET" ,
url : "ajax.php?anketa=" + anketa + "&t=hierarhija-ajax&a=json_jstree" ,
dataType : "json" ,
success : function ( json ) {
if ( typeof refresh === 'undefined' ) {
jstree _vkljuci ( json ) ;
}
else {
//v kolikor imamo jsTree že postavljen samo osvežimo podatke
var $jstree = $ ( '#admin_hierarhija_jstree' ) . jstree ( true ) ;
$jstree . settings . core . data = json ;
$jstree . refresh ( ) ;
}
} ,
error : function ( xhr , ajaxOptions , thrownError ) {
console . log ( thrownError ) ;
}
} ) ;
}
function jstree _vkljuci ( jsonData ) {
$ ( "#admin_hierarhija_jstree" ) . jstree ( {
//'plugins': ['contextmenu', 'dnd', 'massload', 'sort', 'types'],
'plugins' : [ 'search' , 'massload' , 'contextmenu' ] ,
'contextmenu' : {
"items" : function ( $node ) {
return {
"Delete" : {
"label" : "Briši" ,
"action" : function ( data ) {
var ref = $ . jstree . reference ( data . reference ) ,
sel = ref . get _selected ( ) ;
if ( ! sel . length ) {
return false ;
}
ref . delete _node ( sel ) ;
var url = window . location . href ;
var par = url . match ( /(?:anketa=)(\w+)/g ) ;
var anketa _id = par [ 0 ] . slice ( 7 , par [ 0 ] . length ) ;
//pošljemo POST ukaz, da pobrišemo element
brisiVrsticoHierarhije ( $node . id ) ;
}
} ,
//"Edit": {
// "label": "Urejanje uporabnika",
// 'action': function () {
//
//
// }
//}
}
}
} ,
'core' : {
"animation" : 0 ,
"check_callback" : true ,
"expand_selected_onload" : true ,
"themes" : {
"name" : "proton" ,
"responsive" : true
} ,
"data" : jsonData ,
} ,
//"types": {
// "#": {
// "max_children": 1,
// "max_depth": 20,
// "valid_children": ["root"]
// },
// "root": {
// "icon": "glyphicon glyphicon-home",
// "valid_children": ["default"]
// },
// "default": {
// "valid_children": ["default", "file"]
// },
// "file": {
// "icon": "glyphicon glyphicon-home",
// "valid_children": []
// }
//}
} ) . on ( 'loaded.jstree' , function ( ) {
$ ( "#admin_hierarhija_jstree" ) . jstree ( 'open_all' ) ;
} ) . bind ( "select_node.jstree" , function ( event , data ) {
//V kolikor kliknemo na hierarhijo z levim miškinim klikom, potem v meniju select izberemo ustrezne vrednosti
// ko vrednost zberemo iz jstree je potrebno baziti, da preverimo, če je neznan event, ker v nasprotnem primeru submit sproži omenjeno skripto
if ( event . isTrigger == 2 && ( typeof data . event !== "undefined" ) ) {
//Pošljemo id, kamor je bil izveden klik in nato prikažemo ustrezne select opcije
var url = window . location . href ;
var par = url . match ( /(?:anketa=)(\w+)/g ) ;
var anketa _id = par [ 0 ] . slice ( 7 , par [ 0 ] . length ) ;
$ . post ( "ajax.php?anketa=" + anketa _id + "&t=hierarhija-ajax&a=posodobi_sifrante" , {
id : data . node . id
} ) . success ( function ( podatki ) {
var sifrant = JSON . parse ( podatki ) ;
var st _naprej = 2 ;
// najprej je potrebno vsa polja skriti, da nato prikažemo samo potrebna
for ( var st = 1 ; st <= sifrant . user . max _level ; st ++ ) {
$ ( '.h-nivo-' + st ) . val ( '' ) . trigger ( "liszt:updated" ) ; //update chosen list -> v novejših verzijah je chosen:update
$ ( '.h-level-' + st ) . removeClass ( 'h-selected' ) . hide ( ) ;
}
//naredimo zanko po vseh nivojih
$ . each ( sifrant , function ( key , val ) {
//izluščimo samo številke,ker uporabnika ne potrebujemo
if ( $ . isNumeric ( key ) ) {
$ ( '.h-level-' + key ) . addClass ( 'h-selected' ) . show ( ) ;
$ ( '.h-nivo-' + key ) . val ( val . select ) . chosen ( ) . trigger ( "liszt:updated" ) ;
}
} ) ;
// prikažemo še možnost vnos naslednjega elementa
var naslednjiSifrant = data . node . parents . length + 1 ;
// Če uporabnik ni admin, potem ime ŠOLE ne vnesemo v HIERARHIJO in zato nam prikaže en element premalo in je potrebno +1, da nam prikaže možnost vnosa tudi naslednjega elementa
if ( sifrant . user . id _strukture != 'admin' )
naslednjiSifrant += 1 ;
$ ( '.h-level-' + naslednjiSifrant ) . addClass ( 'h-selected' ) . show ( ) ;
$ ( '.h-nivo-' + naslednjiSifrant ) . val ( '' ) . chosen ( ) ;
} ) ;
}
} ) ;
}
function dodajKomentar ( ) {
2021-03-15 12:34:26 +01:00
$ ( '#fade' ) . fadeTo ( 'slow' , 1 ) ;
$ ( '#vrednost_edit' ) . wrapAll ( '<div class="fixed-position"></div>' ) . html ( '' ) . fadeIn ( 'slow' ) . load ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=komentar-k-hierarhiji&m=get' ) ;
2020-08-14 13:36:36 +02:00
}
/ * *
* Odpre popup za nalaganje logotipa
* /
function uploadLogo ( ) {
2021-03-15 12:34:26 +01:00
$ ( '#fade' ) . fadeTo ( 'slow' , 1 ) ;
$ ( '#vrednost_edit' ) . wrapAll ( '<div class="fixed-position"></div>' ) . html ( '' ) . fadeIn ( 'slow' ) . load ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=upload-logo&m=get' , function ( ) {
2020-08-14 13:36:36 +02:00
//Vklopi nice input file
$ ( "input[type=file]" ) . nicefileinput ( {
label : 'Poišči datoteko...'
} ) ;
} ) ;
}
/ * *
* Izbriše logotip , ki je že naložen
* @ param $id
* /
function izbrisiLogo ( $id ) {
var id = $ ( 'form > input[name="id"]' ) . val ( ) ;
$ . post ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=upload-logo&m=delete' , {
id : id
} ) . success ( function ( ) {
$ ( '#hierarhija-logo' ) . remove ( ) ;
} ) ;
}
/**************************** HIERARHIJA END ***************************/
function printElement ( ime ) {
var divToPrint = $ ( '.printElement' ) ;
if ( ime == 'Status' ) {
var objekt = divToPrint . html ( ) ;
divToPrint = '<table class="printTable" id="printHierarhijaStatus">' + objekt + '</table>' ;
} else if ( ime == 'Analize' ) {
divToPrint = document . getElementById ( 'div_means_data' ) . innerHTML ;
}
var newWin = window . open ( '' , ime , 'scrollbars=1' ) ;
newWin . document . write ( '<html><head><title>Okno za tiskanje - ' + ime + '</title>' ) ;
newWin . document . write ( '<meta http-equiv="Cache-Control" content="no-store"/>' ) ;
newWin . document . write ( '<meta http-equiv="Pragma" content="no-cache"/>' ) ;
newWin . document . write ( '<meta http-equiv="Expires" content="0"/>' ) ;
newWin . document . write ( '<link rel="stylesheet" href="css/print.css#13042017">' ) ;
newWin . document . write ( '<link rel="stylesheet" href="css/style_print.css" media="print">' ) ;
newWin . document . write ( '</head><body class="print_analiza">' ) ;
newWin . document . write ( '<div id="printIcon">' ) ;
newWin . document . write ( '<a href="#" onclick="window.print(); return false;">Natisni</a>' ) ;
newWin . document . write ( '</div>' ) ;
newWin . document . write ( divToPrint ) ;
newWin . document . write ( '</body></html>' ) ;
newWin . focus ( ) ;
newWin . document . close ( ) ;
}
/ * *
* Posodobi nastavitve v bazi , za pošiljanje kod samo za učitelja ali tudi za vse
*
* @ param string { vrednost }
* /
function posodobiPosiljanjeKod ( vrednost , val ) {
$ . post ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=ostalo&m=opcije' , {
name : vrednost ,
value : val ,
method : ( val == 0 ? 'delete' : '' )
} ) . success ( function ( ) {
$ ( '#poslji-kode' ) . val ( vrednost ) ;
} ) ;
}
/ * *
* POšlji obvestilo učiteljem , kateri še niso bili obveščeni
*
* @ param { }
* @ return
* /
function obvestiUciteljeZaResevanjeAnkete ( ) {
$ . post ( 'ajax.php?anketa=' + anketa _id + '&t=hierarhija-ajax&a=ostalo&m=poslji-email-samo-uciteljem' ) . success ( function ( ) {
$ ( '#obvesti-samo-ucitelje' ) . html ( '<span style="color:#fa4913;">Elektronsko sporočilo s kodo je bilo posredovano vsem učiteljem, ki so na zgornjem seznamu</span>' ) ;
} ) ;
}
// ker aplikacije ne sprejema JSON potem vuejs emulira json in pošlje kot navadno polje
Vue . http . options . emulateJSON = true ;
// select2 direktiva
Vue . directive ( 'select' , {
twoWay : true ,
priority : 1000 ,
params : [ 'options' ] ,
bind : function ( ) {
var that = this ;
$ ( this . el ) . select2 ( {
width : '100%'
} ) . on ( 'change' , function ( ) {
that . set ( this . value )
} ) ;
} ,
update : function ( value ) {
$ ( this . el ) . val ( value ) . trigger ( 'change' ) ;
} ,
unbind : function ( ) {
$ ( this . el ) . off ( ) . select2 ( 'destroy' )
}
} ) ;
// Definiramo globalne spremenljivke za Vuejs
var gradnjaHierarhijeApp = '' ;
var hierarhijaApp = '' ;
$ ( document ) . ready ( function ( ) {
if ( document . querySelector ( '#hierarhija-app' ) ) {
hierarhijaApp = new Vue ( {
el : '#hierarhija-app' ,
data : {
novaHierarhijaSt : 1 , // številka prve ravni je vedno default 1, in pomeni da še nimamo nobenega vpisa ravni
inputNivo : [ ] ,
anketaId : $ ( '#srv_meta_anketa_id' ) . val ( ) ,
sifrant : '' ,
imeHierarhije : {
shrani : '' ,
aktivna : '' ,
index : '-1' ,
id : '-1' ,
urejanje : false ,
editTitle : false
} ,
prikaziImeZaShranjevanje : false ,
shranjenaHierarhija : [
{
id : 'default' ,
ime : 'Hierarhija Šolski center' ,
anketa : '' ,
stUporabnikov : 0 ,
hierarhija : [
{
st : 1 ,
ime : 'Šolski center' ,
sifranti : [
{ ime : 'Ljubljana' } ,
{ ime : 'Maribor' } ,
{ ime : 'Koper' }
]
} ,
{
st : 2 ,
ime : 'Šola' ,
sifranti : [
{ ime : 'Gimnazija' } ,
{ ime : 'Poklicna šola' }
]
} ,
{
st : 3 ,
ime : 'Program' ,
sifranti : [
{ ime : 'Gimnazijec' } ,
{ ime : 'Fizik' }
]
} ,
{
st : 4 ,
ime : 'Letnik' ,
sifranti : [
{ ime : '1. letnik' } ,
{ ime : '2. letnik' } ,
{ ime : '3. letnik' } ,
{ ime : '4. letnik' }
]
} ,
{
st : 5 ,
ime : 'Razred' ,
sifranti : [
{ ime : 'a' } ,
{ ime : 'b' } ,
{ ime : 'c' } ,
{ ime : 'd' }
]
} ,
{
st : 6 ,
ime : 'Predmet' ,
sifranti : [
{ ime : 'mat' } ,
{ ime : 'fiz' } ,
{ ime : 'slo' } ,
{ ime : 'geo' }
]
}
]
} ,
{
id : 'default' ,
ime : 'Šola' ,
anketa : '' ,
stUporabnikov : 0 ,
hierarhija : [
{
st : 1 ,
ime : 'Letnik' ,
sifranti : [
{ ime : '1. letnik' } ,
{ ime : '2. letnik' } ,
{ ime : '3. letnik' } ,
{ ime : '4. letnik' }
]
} ,
{
st : 2 ,
ime : 'Razred' ,
sifranti : [
{ ime : 'a' } ,
{ ime : 'b' } ,
{ ime : 'c' } ,
{ ime : 'd' }
]
} ,
{
st : 3 ,
ime : 'Predmet' ,
sifranti : [
{ ime : 'mat' } ,
{ ime : 'fiz' } ,
{ ime : 'slo' } ,
{ ime : 'geo' }
]
}
]
}
] ,
defaultHierarhija : '' ,
// omogočimo predogled hierarhije
previewHierarhije : {
vklop : true ,
input : [ ] ,
ime : '' ,
index : '' ,
id : '' ,
uporabniki : 0
} ,
imeNivoja : '' ,
brisanjeDropdownMenija : [ ] , // ali je opcija za meni vklopljena ali izklopljena
vklopiUrejanje : true , // Vklopimo možnost urejanja preimenovanja
vpisanaStruktura : false , // pove nam če je vpisana struktura oz. so dodani uporabniki na hierarhijo
kopirajTudiUporabnike : 0 , // iz seznama shranjenih hierarhij kopiramo tudi uporabnike/strukturo, če je seveda shranjena
} ,
// watch:{
// 'imeHierarhije.shrani':function(val, oldVal){
// this.imeHierarhije.aktivna = val;
// }
// },
ready : function ( ) {
// Pridobi število nivojev
this . pridobiStNivojev ( ) ;
var that = this ;
// Pridobi nivoje in podatke
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=json_nivoji_podatki' ) . success ( function ( data ) {
if ( data != 'undefined' && data . length > 0 ) {
$ . each ( data , function ( index , value ) {
that . inputNivo . push ( value ) ;
} ) ;
}
} ) ;
// Pridobimo shranjene hierarhije v bazi
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=json_shranjene_hierarhije' ) . success ( function ( data ) {
if ( data != 'undefined' && data . length > 0 ) {
$ . each ( data , function ( index , value ) {
that . shranjenaHierarhija . push ( value ) ;
} ) ;
}
} ) ;
// pridobimo vse nastavitve iz baze
this . vseNastavitveIzBaze ( ) ;
} ,
// Pridobimo trenutno število nivojev in dodamo novega
methods : {
// Omogoči možnost preimenovanja ankete
editTitleToogle : function ( ) {
return this . imeHierarhije . editTitle = ! this . imeHierarhije . editTitle ;
} ,
dodajNivoHierarhije : function ( st ) {
var that = this ;
var ime = this . imeNivoja || 'nivo' ;
var st = this . novaHierarhijaSt ;
this . imeNivoja = '' ;
// POST request
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=post_nivoji' , {
nivo : st ,
ime : ime
} ) . success ( function ( data ) {
// ko dobimo id od ravni potem napolnimo dom element inputNivo
that . inputNivo . push ( {
st : st ,
ime : ime ,
id : data ,
sifranti : [ ]
} ) ;
// posodobimo število nivojev
that . pridobiStNivojev ( ) ;
} ) ;
} ,
odstraniNivoHierarhije : function ( index , id ) {
var st = this . inputNivo [ index ] . st ;
this . inputNivo . forEach ( function ( obj ) {
if ( obj . st > st )
obj . st = obj . st - 1 ;
} ) ;
var that = this ;
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=brisi_nivo_hierarhija' , {
id _nivoja : id
} ) . then ( function ( response ) {
if ( response . status == 200 && response . data == 0 ) {
swal ( {
title : "Napaka!" ,
text : "Omenjen nivo ni mogoče izbrisati, ker je že uporabljen pri izgradnji hierarhije." ,
type : "warning" ,
confirmButtonText : "OK"
} ) ;
} else {
that . inputNivo . splice ( index , 1 ) ;
that . novaHierarhijaSt = ( that . novaHierarhijaSt - 1 ) ;
}
} ) ;
} ,
// izbrišemo vse ravni v hierarhiji, da lahko uporabnik na novo ustvarja
izbrisiCelotnoHierarhijo : function ( ) {
// Prejšno hierarhijo vedno shranimo
if ( this . inputNivo . length > 0 )
this . shraniTrenutnoHierarhijo ( ) ;
// Če uporabnik ne vpiše imena potem obstoječo ne brišemo
if ( this . pobrisiHierarhijoInZacniNovo ( ) ) {
// Vse spremenljivke postavimo na 0
this . imeHierarhije = {
aktivna : '' ,
shrani : '' ,
index : '-1' ,
id : '-1'
} ;
this . previewHierarhije . vklop = false ;
}
} ,
// PObrišemo trenutno aktivno hierarhijo in začnemo novo, ki jo tudi shranimo za kasnejši preklic
pobrisiHierarhijoInZacniNovo : function ( ) {
var that = this ;
//# V kolikor dela novo hierarhijo potem vedno prikažemo možnost za vpis imena
swal ( {
title : "Nova hierarhija" ,
text : "Vpišite ime nove hierarhije:" ,
type : "input" ,
animation : "slide-from-top" ,
closeOnConfirm : false ,
closeOnCancel : true ,
showCancelButton : true ,
cancelButtonText : 'Prekliči' ,
allowOutsideClick : true ,
inputPlaceholder : "Primer: Hierarhija šola"
} , function ( inputValue ) {
if ( inputValue === false ) return false ;
if ( inputValue === "" ) {
swal . showInputError ( "Ime hierarhije je obvezno!" ) ;
return false
}
//# Pobrišemo vse ravni in vso trenutno hierarhij v kolikor vpiše novo
that . $http . post ( 'ajax.php?anketa=' + that . anketaId + '&t=hierarhija-ajax&a=izbrisi_vse_ravni' ) ;
// Ime hierarhije shranimo v vue spremenljivko
that . getSaveOptions ( 'aktivna_hierarhija_ime' , inputValue ) ;
that . imeHierarhije . shrani = inputValue ;
// Ime hierarhije shranimo tudi v srv_hierarhija_shrani, da dobimo ID vnosa, kamor potem shranjujemo json podatke z vsemi šifranti in nivoji
that . $http . post ( 'ajax.php?anketa=' + that . anketaId + '&t=hierarhija-ajax&a=shrani_hierarhijo' , {
ime : inputValue ,
hierarhija : null
} ) . success ( function ( id ) {
// shranimo tudi ID hierarhije
that . getSaveOptions ( 'srv_hierarhija_shrani_id' , id ) ;
} ) ;
location . reload ( ) ;
} ) ;
} ,
// Dodamo šifrant k ustreznemu nivoju/ravni
dodajSifrant : function ( index , idNivoja ) {
var text = $ ( '[data-nivo="' + idNivoja + '"]' ) . val ( ) ;
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=post_sifranti' , {
idNivoja : idNivoja ,
imeSifranta : text
} ) . success ( function ( data ) {
this . inputNivo [ index ] . sifranti . push ( {
ime : text
} ) ;
$ ( '[data-nivo="' + idNivoja + '"]' ) . val ( '' ) ;
var opcije = '' ;
$ . each ( data , function ( index , value ) {
opcije += '<option value = "#">' + value + '</option>' ;
} ) ;
$ ( '#nivo-' + idNivoja + ' td:eq( 1 )' ) . html ( '<select name="nivo" data-opcije="' + idNivoja + '">' + opcije + '</select>' ) ;
} ) ;
} ,
brisiSifrant : function ( idNivoja ) {
var that = this ;
// Toogle spremenljivka, ki prikaže urejanje ali drop down meni
if ( typeof this . brisanjeDropdownMenija [ idNivoja ] == 'undefined' )
this . brisanjeDropdownMenija [ idNivoja ] = false ;
this . brisanjeDropdownMenija [ idNivoja ] = ! this . brisanjeDropdownMenija [ idNivoja ] ;
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=brisi_sifrante' , {
idNivoja : idNivoja ,
} ) . success ( function ( data ) {
if ( that . brisanjeDropdownMenija [ idNivoja ] ) {
var opcije = '<div class="sifranti-razmik"><ul>' ;
$ . each ( data , function ( index , value ) {
opcije += '<li class="sifranti-brisanje" data-sifrant="' + value . id + '"><span class="icon brisi-x" onclick="izbrisiSifrant(' + value . id + ')"></span>' + value . ime + '</li>' ;
} ) ;
opcije += '</ul></div>' ;
$ ( '#nivo-' + idNivoja + ' td:eq( 1 )' ) . html ( opcije ) ;
} else {
$ ( '[data-nivo="' + idNivoja + '"]' ) . val ( '' ) ;
var opcije = '' ;
$ . each ( data , function ( index , value ) {
opcije += '<option value = "#">' + value . ime + '</option>' ;
} ) ;
$ ( '#nivo-' + idNivoja + ' td:eq( 1 )' ) . html ( '<select name="nivo" data-opcije="' + idNivoja + '">' + opcije + '</select>' ) ;
}
} ) ;
} ,
posodobiUnikatnega : function ( id , obj ) {
if ( obj . unikaten == 0 ) {
obj . unikaten = 1 ;
} else {
obj . unikaten = 0 ;
}
$ . post ( "ajax.php?anketa=" + this . anketaId + "&t=hierarhija-ajax&a=popravi_nivo_hierarhija" , {
id _nivoja : id ,
unikaten : obj . unikaten
} ) ;
} ,
// posodobi ime labele nivoja
preimenujLabeloNivoja : function ( id ) {
this . $http . post ( "ajax.php?anketa=" + this . anketaId + "&t=hierarhija-ajax&a=popravi_nivo_hierarhija" , {
id _nivoja : id ,
besedilo : $ ( '[data-labela="' + id + '"]' ) . text ( )
} ) ;
} ,
// Pridobimo število nivojev, ki je vpisano za izbrano anketo
pridobiStNivojev : function ( ) {
var that = this ;
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=st_nivojev' ) . success ( function ( data ) {
that . novaHierarhijaSt = ( data + 1 ) ;
if ( data > 0 )
that . previewHierarhije . vklop = false ;
} ) ;
} ,
// Shranimo trenutno izdelano hierarhijo
shraniTrenutnoHierarhijo : function ( shraniPodIstiId ) {
// Če želimo izvesti update ali create new
var shraniPodIstiId = shraniPodIstiId || false ;
// V kolikor samo uporabimo checkbox in je še vedno isto potem naredimo update
if ( this . imeHierarhije . shrani == this . imeHierarhije . aktivna )
shraniPodIstiId = true ;
// preverimo, če je shranjena struktura potem
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=pridobi-shranjeno-hierarhijo-bool' , {
id : this . imeHierarhije . id ,
polje : 'struktura' ,
} ) . then ( function ( response ) {
// UPDATE se vedno zgodi, kadar gremo naprej
if ( shraniPodIstiId && this . imeHierarhije . index > 1 && this . imeHierarhije . index != 'default' ) {
return this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=update-aktivno-hierarhijo' , {
id : this . imeHierarhije . id ,
hierarhija : JSON . stringify ( this . inputNivo )
} ) . success ( function ( ) {
// našo trenutno hierarhijo shranimo tudi v dom, da v kolikor uporabnik še enkrat izbere isto hierarhijo, da se mu naložijo isti elementi
this . shranjenaHierarhija [ this . imeHierarhije . index ] . hierarhija = JSON . stringify ( this . inputNivo ) ;
} ) ;
}
// Hierarhijo shranimo na novo
// če hierarhije ne poimenujemo potem dobi privzeto ime Hierarhija in čas kopiranja ali pa ostoječe ime in čas kopiranja (Šola, Hierarhija Šolski center)
if ( ! this . prikaziImeZaShranjevanje ) {
// Če je že kopija kakšne od preh hierarhije potem dobi obstoječe ime in uro
var time = new Date ( ) ;
if ( this . imeHierarhije . aktivna . length > 0 ) {
// ime_H:i:s"
var sekunde = ( '0' + time . getSeconds ( ) ) . slice ( - 2 ) ;
var minute = ( '0' + time . getMinutes ( ) ) . slice ( - 2 ) ;
var ure = ( '0' + time . getHours ( ) ) . slice ( - 2 ) ;
this . imeHierarhije . shrani = this . imeHierarhije . aktivna + '_' + ure + ':' + minute + ':' + sekunde ;
} else {
// Drugače pa "Hierarhija - H:i:s"
this . imeHierarhije . shrani = 'Hierarhija - ' + time . getHours ( ) + ':' + time . getMinutes ( ) + ':' + time . getSeconds ( ) ;
}
}
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=shrani_hierarhijo' , {
ime : this . imeHierarhije . shrani ,
hierarhija : JSON . stringify ( this . inputNivo )
} ) . then ( function ( responseShrani ) {
this . imeHierarhije . aktivna = this . imeHierarhije . shrani
// SHRANJENO HIERARHIJO shranimo tudi v spremenljivko za kasnejši preklic
this . shranjenaHierarhija . push ( {
id : responseShrani . data ,
ime : this . imeHierarhije . shrani ,
hierarhija : ( typeof this . inputNivo == 'string' ? JSON . stringify ( this . inputNivo ) : this . inputNivo ) ,
anketa : this . anketaId ,
dom : true ,
} ) ;
this . imeHierarhije . index = ( this . shranjenaHierarhija . length - 1 ) ;
// shranimo tudi ID hierarhije
this . getSaveOptions ( 'srv_hierarhija_shrani_id' , responseShrani . data ) ;
this . imeHierarhije . id = responseShrani . data ;
} ) ;
// Ime shranjene hierarhije shranimo tudi kot aktivno hierarhijo
this . getSaveOptions ( 'aktivna_hierarhija_ime' , this . imeHierarhije . shrani ) ;
} ) ;
} ,
/ *
* Gumb za premikanje naprej
* /
premikNaprej : function ( ime ) {
if ( ime == 'uredi-uporabnike' ) {
this . shraniTrenutnoHierarhijo ( false , true ) ;
// Preusmerimo na urejanje uporabnikov in naredimo cel reload ter pobrišemo cache
window . location . replace ( location . origin + location . pathname + "?anketa=" + this . anketaId + "&a=hierarhija_superadmin&m=uredi-uporabnike" ) ;
}
} ,
/ *
* Uporabimo shranjeno hierarhijo iz seznama
* /
uporabiShranjenoHierarhijo : function ( index , id , uporabniki ) {
var that = this ;
// Tukaj moram imeti podatke še o starih stvareh
this . imeHierarhije . id = id ;
this . uporabnikiZaKopijo = uporabniki || 0 ;
if ( this . vpisanaStruktura )
return swal ( {
title : "Opozorilo!" ,
text : "Pri omenjeni strukturi hierarhije so že dodani uporabniki in nove hierarhije ni več mogoče izbrati, lahko samo dopolnjujete obstoječo." ,
type : "warning" ,
confirmButtonText : "Zapri"
} ) ;
// Kadar še nimamo vpisane nobene ravni
if ( this . novaHierarhijaSt == 1 )
return that . posodobiHierarhijo ( index , id ) ;
swal ( {
title : "Kopiranje hierarhije" ,
text : "Z nadaljevanjem se bo hierarhija skopirala v novo ime, obstoječa pa se bo avtomatsko shranila pod dosedanje ime." ,
type : "info" ,
showCancelButton : true ,
cancelButtonText : "Ne" ,
confirmButtonText : "Da, nadaljuj."
} , function ( shrani ) {
if ( shrani ) {
// V kolikor želi uporabnik shraniti trenutno hierarhijo in pustimo index kot je
that . shraniTrenutnoHierarhijo ( true ) ;
setTimeout ( function ( ) {
Vue . nextTick ( function ( ) {
// Izberemo novo hierarhijo
that . posodobiHierarhijo ( index , id ) ;
} ) ;
} , 100 ) ;
}
} ) ;
} ,
// Preglej shranjeno hierarhijo in ne shrani v bazo
pregledShranjeneHierarhije : function ( index , id , uporabniki ) {
// Nastavitve trenutne strukture na katero je kliknil uporabnik shranimo v predogled, da se lahko uporabi v kolikor bi uporabnik želel uporabiti omenjeno hierarhijo
this . previewHierarhije = {
vklop : true ,
ime : this . shranjenaHierarhija [ index ] . ime ,
index : index ,
id : id ,
uporabniki : uporabniki
} ;
if ( typeof this . shranjenaHierarhija [ index ] . hierarhija == 'object' )
this . previewHierarhije . input = this . shranjenaHierarhija [ index ] . hierarhija ;
else
this . previewHierarhije . input = JSON . parse ( this . shranjenaHierarhija [ index ] . hierarhija ) ;
} ,
// Izklopimo predogled hierarhije
izklopiPredogled : function ( ) {
this . previewHierarhije = {
vklop : false ,
ime : '' ,
index : '' ,
id : '' ,
uporabniki : 0 ,
input : [ ]
} ;
} ,
// Uporabnik je iz predogleda izbral željeno hierarhijo, ki se bo aktivirala
aktivirajIzbranoHierarhijo : function ( ) {
this . uporabiShranjenoHierarhijo ( this . previewHierarhije . index , this . previewHierarhije . id , this . previewHierarhije . uporabniki ) ;
} ,
posodobiHierarhijo : function ( index , id ) {
var that = this ;
// dodamo active class
this . imeHierarhije . index = index ;
// Če urejamo hierarhijo potem nič ne urejamo sql baze in klik na ime hierarhije omogoči samo preimenovanje in brisanje
if ( this . imeHierarhije . urejanje )
return '' ;
// preimenujemo Hierarhijo
this . imeHierarhije . aktivna = this . shranjenaHierarhija [ index ] . ime ;
// // shranimo ime hierarhije in trenuten id izbrane hierarhije v opcije
// this.getSaveOptions('aktivna_hierarhija_ime', this.imeHierarhije.aktivna);
// this.getSaveOptions('srv_hierarhija_shrani_id', id);
// Kadar prikličemo hierarhijo, ki je prazna, smo izbrali samo ime potem nič ne vrnemo, vse postavimo na nič
if ( this . shranjenaHierarhija [ index ] . hierarhija == '' ) {
this . inputNivo = [ ] ;
this . novaHierarhijaSt = 1 ;
// naloži šifrante, ker imamo šifrante v JSON.stringfy moramo anredite revers v object in če je object potem samo zapišemo v spremenljivko, drugače pa delamo reverse
} else if ( ( index < 2 || id === 'default' ) && typeof this . shranjenaHierarhija [ index ] . hierarhija == 'object' ) {
this . inputNivo = this . shranjenaHierarhija [ index ] . hierarhija ;
} else {
this . inputNivo = JSON . parse ( this . shranjenaHierarhija [ index ] . hierarhija ) ;
}
// prevzeto ne kopira uporabnikov, samo če pote če potrdi iz seznama
this . kopirajTudiUporabnike = 0 ;
// pošljemo ravni in nivoje ter shranimo vse potrebno v
if ( this . uporabnikiZaKopijo == 1 ) {
setTimeout ( function ( ) {
swal ( {
title : "Opozorilo!" ,
text : "Ali želite kopirati tudi strukturo uporabnikov?" ,
type : "info" ,
showCancelButton : true ,
cancelButtonText : "Ne" ,
confirmButtonText : "Da, tudi uporabnike."
} , function ( shrani ) {
if ( shrani )
that . kopirajTudiUporabnike = 1 ;
Vue . nextTick ( function ( ) {
that . $http . post ( 'ajax.php?anketa=' + that . anketaId + '&t=hierarhija-ajax&a=obnovi-hierarhijo' , {
hierarhija : that . inputNivo ,
uporabniki : that . kopirajTudiUporabnike ,
id : id
} ) . success ( function ( data ) {
that . inputNivo = [ ] ;
if ( data != 'undefined' && data != '' && data . length > 0 )
$ . each ( data , function ( index , value ) {
that . inputNivo . push ( value ) ;
} ) ;
that . shraniTrenutnoHierarhijo ( ) ;
// posodobimo število nivojev
that . pridobiStNivojev ( ) ;
} ) ;
} ) ;
} ) ;
} , 100 ) ;
} else {
Vue . nextTick ( function ( ) {
that . $http . post ( 'ajax.php?anketa=' + that . anketaId + '&t=hierarhija-ajax&a=obnovi-hierarhijo' , {
hierarhija : that . inputNivo ,
uporabniki : that . kopirajTudiUporabnike ,
id : id
} ) . success ( function ( data ) {
that . inputNivo = [ ] ;
if ( data != 'undefined' && data != '' && data . length > 0 )
$ . each ( data , function ( index , value ) {
that . inputNivo . push ( value ) ;
} ) ;
that . shraniTrenutnoHierarhijo ( ) ;
// posodobimo število nivojev
that . pridobiStNivojev ( ) ;
} ) ;
} ) ;
}
} ,
// shrani ali pridobi opcije iz baze
getSaveOptions : function ( option , value , response ) {
if ( typeof value != 'undefined' && typeof response == 'undefined' )
response = 'save' ;
if ( typeof value == 'undefined' && typeof response == 'undefined' )
response = 'get' ;
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=hierarhija-options&m=' + response , {
option _name : option || '' ,
option _value : value || ''
} , function ( data ) {
return data ;
} ) ;
} ,
// ko zapustimo urejanje/preimenovanje potem spremenimo tudi dom
preimenujHierarhijo : function ( index , id ) {
var ime = $ . trim ( $ ( '.h-ime-shranjeno.editable-hierarhija' ) . html ( ) ) ;
//odstranimo html tag
var div = document . createElement ( 'div' ) ;
div . innerHTML = ime ;
ime = $ . trim ( div . innerText ) ;
var ime _dom = this . shranjenaHierarhija [ index ] . ime ;
// V kolikor je bila preimenova aktivna anketa moramo tudi v bazi med opcijami preimenovati
if ( this . imeHierarhije . aktivna == ime _dom )
this . getSaveOptions ( 'aktivna_hierarhija_ime' , ime ) ;
// v kolikor je zbrisano celotno ime ponovno damo na default
if ( id == 'default' || ime . length == 0 || this . shranjenaHierarhija [ index ] . ime . length == 0 )
return $ ( '.h-ime-shranjeno.active' ) . html ( ime _dom ) ;
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=preimenuj-hierarhijo' , {
id : id ,
ime : ime
} , function ( ) {
//v kolikor smo v bazi uspešno preimenovali potem tudi v naši spremenljivki preimenujemo
this . shranjenaHierarhija [ index ] . ime = ime ;
} ) ;
} ,
izbrisiShranjenoHierarhijo : function ( index , id ) {
if ( id == 'default' || id == this . imeHierarhije . id )
return '' ;
// post request, ki izbriše iz baze
var obvestilo = this . deleteHierarhijaShrani ( id ) ;
if ( obvestilo )
this . shranjenaHierarhija . splice ( index , 1 ) ;
} ,
// Uvoz in izviz hierarhije v CSV
uvozHierarhije : function ( ) {
2021-03-15 12:34:26 +01:00
$ ( '#fade' ) . fadeTo ( 'slow' , 1 ) ;
2020-08-14 13:36:36 +02:00
$ ( '#vrednost_edit' ) . html ( '' ) . fadeIn ( 'slow' ) . load ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=uvozi-hierarhijo' , function ( ) {
//Vklopi nice input file
$ ( "input[type=file]" ) . nicefileinput ( {
label : 'Poišči datoteko...'
} ) ;
} ) ;
var position = $ ( window ) . scrollTop ( ) ;
$ ( '#vrednost_edit' ) . css ( 'top' , position + 300 ) ;
} ,
izvozHierarhije : function ( ) {
this . $http . get ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=izvoz-hierarhije' ) ;
} ,
// pridobimo vse nastavitve iz baze
vseNastavitveIzBaze : function ( ) {
var that = this ;
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=hierarhija-options&m=get' ) . success ( function ( data ) {
$ . each ( data , function ( index , value ) {
if ( index == 'aktivna_hierarhija_ime' ) {
// za prikaz naslova hierarhije
that . imeHierarhije . aktivna = value ;
// polje za shranjevanje, da shrani v enako hierarhijo
that . imeHierarhije . shrani = value ;
// Če imamo ime hierarhije potem nimamo predogleda
if ( value . length > 0 )
that . previewHierarhije . vklop = false ;
// that.imeHierarhije.index = (that.shranjenaHierarhija.length - 1);
}
if ( index == 'admin_skrij_urejanje_nivojev' )
that . vklopiUrejanje = ( value == 'true' ? true : false ) ;
if ( index == 'srv_hierarhija_shrani_id' ) {
// na levi strani izbere ustrezno hierarhijo, moramo nastavit timeout, ker drugače ne pridobimo vseh hierarhij
setTimeout ( function ( ) {
Vue . nextTick ( function ( ) {
$ . each ( that . shranjenaHierarhija , function ( i , val ) {
if ( val . id == value ) {
that . imeHierarhije . index = i ;
that . imeHierarhije . id = value ;
}
} ) ;
} ) ;
} , 100 ) ;
}
// V kolikor imamo vpisano struktur
if ( index == 'vpisana_struktura' )
that . vpisanaStruktura = value ;
} ) ;
} ) ;
} ,
posodobiOpcijeHierarhije : function ( ) {
if ( this . imeHierarhije . urejanje )
this . vseNastavitveIzBaze ( ) ;
} ,
/ * *
* Če smo hierarhijo prvič aktivirali potem ponudi popup za vpis imena in shrani ime hierarhije v bazo
* /
hierarhijoSmoAktivirali : function ( ) {
var that = this ;
if ( this . inputNivo . length == 0 && this . imeHierarhije . aktivna == '' && this . imeHierarhije . shrani == '' )
swal ( {
title : "Nova hierarhija" ,
text : "Vpišite ime nove hierarhije:" ,
type : "input" ,
animation : "slide-from-top" ,
closeOnConfirm : false ,
closeOnCancel : true ,
inputPlaceholder : "Primer: Hierarhija šola"
} , function ( inputValue ) {
if ( inputValue === false ) return false ;
if ( inputValue === "" ) {
swal . showInputError ( "Ime hierarhije je obvezno!" ) ;
return false
}
// Ime hierarhije shranimo v vue spremenljivko
that . getSaveOptions ( 'aktivna_hierarhija_ime' , inputValue ) ;
that . imeHierarhije . shrani = inputValue ;
that . imeHierarhije . aktivna = inputValue ;
swal . close ( ) ;
} ) ;
} ,
/ * *
* Pobriše shranjeno hierarhijo v tabeli srv _hierarhija _shrani
* /
deleteHierarhijaShrani : function ( id ) {
var id = id || 0 ;
var obvestilo = false ;
if ( id == 0 )
return console . log ( 'brez Id-ja' ) ;
// post request, ki izbriše iz baze
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=izbrisi-hierarhijo' , {
id : id
} ) . then ( function ( response ) {
if ( response . data == 'success' )
obvestilo = true ;
return obvestilo ;
} ) ;
return obvestilo ;
} ,
/ * *
* Dodaj komentar k hierarhiji
* /
dodajKomentar : function ( ) {
dodajKomentar ( ) ;
} ,
/ * *
* Odpre popup za nalaganje logotipa
* /
logoUpload : function ( ) {
uploadLogo ( ) ;
}
}
} ) ;
}
if ( document . querySelector ( '#vue-gradnja-hierarhije' ) ) {
gradnjaHierarhijeApp = new Vue ( {
el : '#vue-gradnja-hierarhije' ,
data : {
anketaId : $ ( '#srv_meta_anketa_id' ) . val ( ) ,
pageLoadComplete : false ,
vpisanaStruktura : false , // pove nam, če je uporabnik že vpisal kakšno strukturo, da s tem zaklenemo vpis novih ravni (obstoječa struktura ne bi bila ok)
izbran : {
skrij : 1 ,
sifrant : [ ] ,
strukturaId : [ ] ,
sifrantPodatki : [ ] ,
parent : [ ] ,
} ,
// tukaj vpišemo št. nivoja, ki je key in nato sifrante
podatki : [ ] ,
// V kolikor uporabnik ni superadmin/admin potem podtke, ki so nad njegovim ali enake njegovemu nivoju pridobimo kot fiksne in se jih ne da spreminjati
fiksniPodatki : [ ] ,
// pri vpisu oseb na ustrezni nivo
osebe : {
prikazi : false ,
nivo : 0 ,
vpisane : [ ] , // key je številka nivoja, in potem notri imam object s podatki o osebah
nove : [ ] , // key je številka nivoja in nato notri object s podatki o osebah
textarea : '' ,
show : [ ] // boolean, glede na nivo, da pokaže uporabnike pod šifranti
} ,
// podatki o uporabniku, ki ni admin
user : {
struktura : [ ] ,
uporabnik : [ ] ,
dropdown : [ ] ,
selected : ''
} ,
// vpis emaila preko textarea
email : {
napake : [ ] ,
opozorilo : false
} ,
elektronskiNaslovi : [ {
email : "prvi@email.si" ,
ime : "Prvo Ime"
} , {
email : "drugi@email.si" ,
ime : "Drugi email"
} ] ,
} ,
watch : {
'user.selected' : function ( val ) {
if ( typeof val !== 'undefined' && val !== null && val . length > 0 )
this . vpisemoUporabnikaIzDropDownMenija ( ) ;
}
} ,
computed : { } ,
ready : function ( ) {
var that = this ;
// Pridobimo omejitve uporabnika
this . preveriNivoInPraviceUporabnika ( ) ;
// Pridobimo vse nivoje in šifrante neglede na status uporabnika
this . naloziVseNivojeInSifrante ( ) ;
// Ko je celoten JS in spletna stran naložena potem spremenimo select2 change event, da deluje
document . onreadystatechange = function ( ) {
// Ko je stran čisto naložena izvedemo kodo
if ( document . readyState === 'complete' ) {
// potrebno, ker drugače v FF in IE stvar ne deluje, da je zakasnitev 300ms in se počaka potem na naslednjo spremembo
setTimeout ( function ( ) {
Vue . nextTick ( function ( ) {
// Prikažemo prvi nivo
that . pageLoadComplete = true ;
// Select 2 event
$ ( ".select2" ) . on ( 'change' , function ( ) {
// uogtotovimo, kje smo spremenili podatek
var st = that . izbran . sifrant . length ;
var level = $ ( this ) . attr ( 'data-level' ) ;
that . izbran . sifrant . forEach ( function ( value , key ) {
if ( key > level ) {
for ( var i = key ; i < st ; i ++ ) {
that . izbran . sifrantPodatki . $set ( i , null ) ;
that . izbran . sifrant [ i ] = "" ;
}
}
} ) ;
// Zanka po vseh nivojih, kateri so vpisani
that . izbran . sifrant . forEach ( function ( value , key ) {
if ( typeof value != 'undefined' && value . length > 0 && ! isNaN ( value ) && that . izbran . sifrant [ key ] . length > 0 ) {
that . preveriSifrantZaIzbranNivo ( value , key )
}
} ) ;
} ) ;
} ) ;
} , 600 ) ;
// Dodamo še možnost helpa v kolikor obstaja
load _help ( ) ;
}
}
// Pridobi, če so že vpisani šifranti
this . pridobiNastavitveCeJeVpisanaStruktura ( ) ;
// Pridobimo uporabnikeza dropdown meni user
this . pridobiUporabnikeZaDropdownList ( ) ;
} ,
methods : {
// Preverimo, če je uporabnik admin ali je uporabnik s pravicami na določenem nivoju
preveriNivoInPraviceUporabnika : function ( ) {
var that = this ;
// preverimo pravico in pridobimo že vpisano strukturo nad uporabikom
this . $http . get ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=get-user-level' , function ( data ) {
// pridobimo polji (uporabnik, struktura), v kolikor je admin ni podatka o strukturi
that . user = data ;
if ( data . uporabnik != 1 && data . struktura ) {
// ID strukture, ki je fiksna zapišemo v spremenljivko
data . struktura . forEach ( function ( val ) {
that . izbran . strukturaId . $set ( val . izbrani . level , val . izbrani . id ) ;
// Že izbrano strukturo vpišemo v sifrantiPodatki, kjer se dodajajo tudi še na novo dodani podatki
that . izbran . sifrantPodatki . $set ( val . izbrani . level , val . izbrani ) ;
} ) ;
}
} ) ;
} ,
// Naložimo vse nivoje in pripadajoče šifrante
naloziVseNivojeInSifrante : function ( ) {
var that = this ;
// pridobi šifrante za ustrezni nivo, če ni nič izbrano potem vedno pridobi šifrante za prvi nivo
this . $http . get ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=get-sifranti' , function ( data ) {
data . nivoji . forEach ( function ( val ) {
val . sifranti = [ ] ;
// vpišemo nivo in pdoatke nivoja
that . podatki . push ( val ) ;
// pole $(this.el).on('change', )g nivoja vpišemo še podatke o šifrantih
data . sifranti . forEach ( function ( options ) {
// tukaj zapišemo šifrante na ustrezen nivo, edino tukaj upoštevamo, da številka nivoja je za 1 manšja, ker če 0 pustimo potem pri prikazuso težave, nivo 1 je element 0
if ( val . level == options . level )
that . podatki [ ( val . level - 1 ) ] . sifranti . push ( options ) ;
} ) ;
} ) ;
// Max število nivojev za validacije
that . podatki . maxLevel = data . maxLevel ;
} ) ;
} ,
// Preveri, če je šifrant za izbran nivo že vpisan v podatkovno bazo
preveriSifrantZaIzbranNivo : function ( sifrant , nivo ) {
var that = this ;
// Parent vedno vzamemo id elementa, ki je vpisan en nivo prej
var parent _id = ( this . izbran . sifrantPodatki [ nivo - 1 ] ? this . izbran . sifrantPodatki [ nivo - 1 ] . id : null ) ;
Vue . nextTick ( function ( ) {
// var parent_id2 = (that.izbran.sifrantPodatki[nivo - 1] ? that.izbran.sifrantPodatki[nivo - 1].id : null);
that . $http . post ( 'ajax.php?anketa=' + that . anketaId + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=preveri-sifrant-za-nivo' , {
level : nivo ,
hierarhija _sifranti _id : sifrant ,
parent _id : parent _id
} ) . then ( function ( i ) {
if ( i . data == 0 ) {
// V kolikor omenjen id šifranta še ne obstaja v strukturi potem shranimo v polje novSifrant, da ga pri sumbitu upoštevamo
that . izbran . sifrantPodatki . $set ( nivo , {
id : null ,
level : nivo ,
hierarhija _sifranti _id : sifrant ,
hierarhija _ravni _id : that . podatki [ nivo - 1 ] . id ,
parent _id : parent _id
} ) ;
} else {
// shranimo na ključ, kjer je nivo celo polje
that . izbran . sifrantPodatki . $set ( i . data . level , i . data ) ;
}
// Preverimo, za nivo, če lahko prikažemo uporabnike
that . prikaziUporabnike ( nivo ) ;
} ) ;
// DOM updated
} ) ;
} ,
// Potrdimo vpis šifrantov, ki smo jih izbrali
submitSifrante : function ( ) {
var that = this ;
// Preverimo, če je bil dodan kak nov elemepridobiIdSifrantovInUporabnikent
var prestejNove = 0 ;
this . izbran . sifrantPodatki . forEach ( function ( val ) {
if ( val != null && val . id == null && ! isNaN ( val . id ) )
prestejNove ++ ;
} ) ;
if ( prestejNove == 0 )
return swal ( {
title : "Opozorilo!" ,
text : "<div style='text-align: left;'>Vse vrstice so že prenesene v hierarhijo:" +
"<ul><li>Bodisi vnesite novega učitelja in njegov predmet.</li>" +
"<li>Bodisi zaključite z vnosom in s klikom na gumb NAPREJ (spdaj desno) aktivirajte hierarhijo.</li></ul></div>" ,
type : "error" ,
html : true
} ) ;
var st = this . podatki . maxLevel ;
// Če je vnešen zadnji nivo, object ni null in ni vpisanih oseb, ker na zadnjem nivo morajo biti vpisane osebe
if ( that . izbran . sifrantPodatki [ st ] != null && ( typeof this . osebe . nove [ st ] == 'undefined' || this . osebe . nove [ st ] . length == 0 ) )
return swal ( {
title : "Opozorilo!" ,
text : "Na zadnjem nivoju morate obvezno vpisati elektronski naslov osebe." ,
type : "error"
} ) ;
// Izpišemo opozorilo, če uporabnik ni vnesel zadnjega nivoja
if ( that . izbran . sifrantPodatki [ st ] == null )
swal ( {
title : "Opozorilo!" ,
text : "Niste vpisali zadnjega nivoja." ,
type : "warning" ,
timer : 2000
} ) ;
// Posredujemo podatke za shranjevanje
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=post-struktura' , {
vnos : that . izbran . sifrantPodatki ,
osebe : that . osebe . nove
} ) . then ( function ( ) {
//Tukaj moramo osvežiti vse šifrante, v dataTables in JsTree, omenjeni funkciji sta v custom.js - splošni jquery
tabela . ajax . reload ( null , false ) ;
jstree _json _data ( that . anketaId , 1 ) ;
// Če je bil izdan zadnji nivo od vseh mogočih potem odstranimo element izbire iz zadnjega nivoja
if ( typeof that . izbran . sifrant [ that . podatki . maxLevel ] != 'undefined' && that . izbran . sifrant [ that . podatki . maxLevel ] . length > 0 ) {
// Zadnji nivo odstranimo iz select2 izbire
that . izbran . sifrant . splice ( that . podatki . maxLevel , 1 ) ;
// Izbrišemo tudi vse podatke o izbranem elementu iz DOM-a
that . izbran . sifrantPodatki . splice ( that . podatki . maxLevel , 1 ) ;
//postavimo spremenljivko na true, da prikaže drugačen tekst pri navodilih
$ ( '.srv_hierarchy_user_help' ) . hide ( ) ;
$ ( '.srv_hierarchy_user_help_sifrant_vnesen' ) . show ( ) ;
}
// Osveži podatke o vseh šifrantih, ki so izbrani in so bili na novo dodani
that . preveriBazoZaSifrant ( null , 1 ) ;
// Polje z na novo dodanimi osebami se izprazni
that . osebe . nove = [ ] ;
//Odstrani besedilo Uporabnik/i iz zadnjega polja, ker ga še tako odstranimo
that . osebe . show . $set ( st , false ) ;
// Zapišemo spremembo, da je struktura vnešena
that . aliJeStrukturaVnesena ( ) ;
// Shanimo celotno strukturo v string in srv_hierarhija_shrani
that . shraniUporabnikeNaHierarhijo ( ) ;
} ) ;
} ,
// Klik na ikono osebe, prikaže spodaj opcijo za vpis oseb
prikaziVnosOseb : function ( level ) {
// V kolikor kliknemo na isto ikono 2x potem uporabimo toggle opcijo
if ( level == this . osebe . nivo )
return this . osebe . prikazi = ! this . osebe . prikazi ;
this . osebe . prikazi = true ;
return this . osebe . nivo = level ;
} ,
vpisemoUporabnikaIzDropDownMenija : function ( ) {
this . osebe . nove [ this . osebe . nivo ] = [ this . user . selected . split ( ',' ) ] ;
// Prikažemo polje z uporabniki, ki so bili na novo dodani
this . prikaziUporabnike ( this . osebe . nivo ) ;
// Tekstovno polje spraznimo in ga skrijemo
this . user . selected = null ;
this . osebe . prikazi = false ;
} ,
vpisOsebNaNivoTextarea : function ( ) {
var that = this ;
// preverimo email in vrnemo napako, če obstaja
if ( this . preveriPravilnostEmaila ( ) )
return this . email . opozorilo ;
if ( typeof this . user . selected !== 'undefined' && this . user . selected && this . user . selected . length > 0 ) {
var vpis = [ this . user . selected ] ;
} else {
// uporabnike razdelimo glede na \n in jih shranimo v polje
var vpis = this . osebe . textarea . split ( '\n' ) ;
}
this . osebe . nove . $set ( that . osebe . nivo , [ ] ) ;
// ločimo še vejice
$ . each ( vpis , function ( key , val ) {
var loci = val . split ( ',' ) ;
// če je email večji od 4 znakov, ga shranimo kot novega drugače ne
if ( loci [ 0 ] . length > 4 ) {
that . osebe . nove [ that . osebe . nivo ] . push ( loci ) ;
}
} ) ;
// Prikažemo polje z uporabniki, ki so bili na novo dodani
this . prikaziUporabnike ( this . osebe . nivo ) ;
// Tekstovno polje spraznimo in ga skrijemo
this . osebe . textarea = '' ;
this . osebe . prikazi = false ;
this . user . selected = '' ;
} ,
// Preveri, če string ustreza pravilnemu zapis emaila
preveriEmail : function ( email ) {
var EMAIL _REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ ;
return EMAIL _REGEX . test ( email ) ;
} ,
// Preverimo pravilnost vpisanega emaila in vržemo napako
preveriPravilnostEmaila : function ( ) {
var that = this ;
// uporabnike razdelimo glede na \n in jih shranimo v polje
var vpis = this . osebe . textarea . split ( '\n' ) ;
// vse napake postavimo na 0
this . email . napake = [ ] ;
// ločimo še vejice
$ . each ( vpis , function ( key , val ) {
var loci = val . split ( ',' ) ;
if ( ! that . preveriEmail ( loci [ 0 ] ) && loci [ 0 ] . length > 0 ) {
that . email . napake . push ( {
naslov : loci [ 0 ] ,
vrstica : ( key + 1 )
} ) ;
}
} ) ;
// v kolikor so v poju zapisani napačni email naslovi potem prikažemo opozorilo
if ( this . email . napake . length > 0 )
return this . email . opozorilo = true ;
} ,
// Preverimo, če uporabniki so že vpisani v bazi in jih prikažemo ali če so bili uporabniki na novo dodani
prikaziUporabnike : function ( level ) {
// Uporabniki so bili na novo dodani na nivo
if ( this . osebe . nove [ level ] && this . osebe . nove [ level ] . length > 0 )
return this . osebe . show . $set ( level , true ) ;
// imamo uporabni v SQL bazi
if ( this . izbran . sifrantPodatki [ level ] && this . izbran . sifrantPodatki [ level ] . uporabniki )
return this . osebe . show . $set ( level , true ) ;
return this . osebe . show . $set ( level , false ) ;
} ,
// Izbriši uporabnika iz this.osebe.nove
izbrisiUporabnika : function ( level ) {
return this . osebe . nove . splice ( level , 1 ) ;
} ,
// Izbriši uporabnika iz Sql baze, ker je že shranjen
izbrisiUporabnikaIzBaze : function ( userId , index , level ) {
var that = this ;
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=brisi&m=uporabnika' , {
uporabnik _id : userId ,
struktura _id : this . izbran . sifrantPodatki [ level ] . id
} ) . then ( function ( ) {
that . izbran . sifrantPodatki [ level ] . uporabniki . splice ( index , 1 ) ;
} ) ;
} ,
// Preverimo v SQL-u, da dobimo za vpisane šifrante ID in parent_id
// Rekurzivna funkcija, ki ob sumbitu preveri v bazi in vsem še obstoječim šifrantom doda id in parent_id
preveriBazoZaSifrant : function ( parent _id , key ) {
var that = this ;
// Polje z omenjenim elementom mora obstajati, drugače smo prišli do konca
if ( this . izbran . sifrantPodatki [ key ] ) {
// V kolikor element že ima parent id, potem tega elementa ne preverjamo in gremo preverit naslednji element
// Prvi element vedno preverimo (key == 1)
if ( key > 1 && this . izbran . sifrantPodatki [ key ] && this . izbran . sifrantPodatki [ key ] . parent _id != 'null' ) {
var st = key + 1 ;
this . preveriBazoZaSifrant ( this . izbran . sifrantPodatki [ key ] . id , st ) ;
}
// AJAX request, da preveri podatke o elementu in pridobi parent_id
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=preveri-sifrant-za-nivo' , {
level : this . izbran . sifrantPodatki [ key ] . level ,
hierarhija _sifranti _id : this . izbran . sifrantPodatki [ key ] . hierarhija _sifranti _id ,
parent _id : parent _id
} ) . then ( function ( i ) {
// shranimo na ključ, kjer je nivo celo polje
that . izbran . sifrantPodatki . $set ( i . data . level , i . data ) ;
// V kolikor vsebuje podatke o uporabnikih potem te rudi prikaže
that . prikaziUporabnike ( i . data . level ) ;
// Pridobimo številko naslednjega elementa
var st = 1 + Number ( i . data . level ) ;
// Pokličemo rekurzivno funkcijo, da kjer je paren_id, id trenutnega elementa
that . preveriBazoZaSifrant ( i . data . id , st ) ;
} ) ;
}
return 0 ;
} ,
// pridobimo vse nastavitve iz baze
pridobiNastavitveCeJeVpisanaStruktura : function ( ) {
var that = this ;
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=hierarhija-options&m=get' ) . success ( function ( data ) {
if ( data . length == 0 )
return that . vpisanaStruktura = false ;
$ . each ( data , function ( index , value ) {
if ( index == 'vpisana_struktura' )
that . vpisanaStruktura = value ;
} ) ;
} ) ;
} ,
// Preveri, če obstaja med opcijami vpisana_struktura, drugače jo vnese
aliJeStrukturaVnesena : function ( ) {
if ( this . vpisanaStruktura )
return this . vpisanaStruktura ;
// V kolikor gre za vpis v bazo
hierarhijaApp . getSaveOptions ( 'vpisana_struktura' , 1 ) ;
this . vpisanaStruktura = 1 ;
} ,
// Preverimo, je izbran element za sledeči nivo, če je nivo večje kot zadnje nivo in če na zadnjem nivoju še ni vpisanega uporabnika potem dovoli prikaz ikone za vnos uporabnikov
aliPrikazemIkonoZaDodajanjeUporabnikov : function ( level ) {
var level = level || false ;
if ( ! level )
return false ;
if ( this . izbran . sifrant [ level ] > 0 &&
( level < this . podatki . maxLevel ||
level == this . podatki . maxLevel &&
this . izbran . sifrantPodatki [ level ] &&
! this . izbran . sifrantPodatki [ level ] . hasOwnProperty ( 'uporabniki' ) )
)
return true ;
return false ;
} ,
/ *
* Pridobimo vse ID - je že vpisanih šifrantov skupaj z uporabniki
* izhajamo pa iz zadnjega ID - ja
* /
pridobiIdSifrantovInUporabnike : function ( idLast ) {
var that = this ;
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=kopiranje-vrstice' , {
id : idLast
} ) . then ( function ( response ) {
// response ok in imamo objekt
if ( response . status == 200 && response . data . length > 0 ) {
response . data . forEach ( function ( val ) {
that . izbran . sifrantPodatki . $set ( val . izbrani . level , val . izbrani ) ;
$ ( 'option[value="' + val . izbrani . hierarhija _sifranti _id + '"]' ) . parent ( ) . val ( val . izbrani . hierarhija _sifranti _id ) . trigger ( 'change' ) ;
} ) ;
$ ( window ) . scrollTop ( 0 ) ;
}
} ) ;
} ,
/ * *
* Shranimo celotno strukturo z uporabniki v srv _hierarhija _shrani
* /
shraniUporabnikeNaHierarhijo : function ( ) {
this . $http . post ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=shrani-strukturo-hierarhije' , {
id : this . anketaId ,
shrani : 1
} ) ;
} ,
/ * *
* Pridobimo uporabnike , ki jih imamo shranjene v bazi za drop down list
* /
pridobiUporabnikeZaDropdownList : function ( ) {
var that = this ;
this . $http . get ( 'ajax.php?anketa=' + this . anketaId + '&t=hierarhija-ajax&a=gradnja-hierarhije&m=import-user&s=getAll' ) . success ( function ( data ) {
that . user . dropdown = data ;
} ) ;
} ,
/**************** funkcije, ki preveri true/false **************/
preveriCejeEmailZeVnesenVbazoZaUcitelja : function ( maxLevel ) {
var maxLevel = maxLevel || 0 ;
if ( maxLevel === 0 || this . izbran . sifrantPodatki [ maxLevel ] !== null )
return false ;
if ( this . izbran . sifrantPodatki [ maxLevel ] !== null && this . izbran . sifrantPodatki [ maxLevel ] . uporabniki . length > 0 )
return true ;
return false ;
} ,
prikaziJsKoSeJeCelaSpletnaStranZeNalozila : function ( level ) {
var level = level || 0 ;
if ( ( level == 1 && this . pageLoadComplete ) || ( this . izbran . sifrant [ level - 1 ] > 0 && this . izbran . sifrant [ level - 1 ] . length > 0 ) )
return true ;
return false ;
} ,
prikaziSelectZaZadnjiNivo : function ( level ) {
var level = level || 0 ;
this . osebe . nivo = level ;
var prikazi = this . aliPrikazemIkonoZaDodajanjeUporabnikov ( level ) ;
if ( level === this . podatki . maxLevel && this . user . dropdown && prikazi )
return true ;
return false ;
} ,
} ,
} ) ;
}
if ( document . querySelector ( '#vue-custom' ) ) {
new Vue ( {
el : '#vue-custom' ,
data : {
anketaId : $ ( '#srv_meta_anketa_id' ) . val ( ) ,
managerOznaciVse : true ,
statusTabela : '' ,
supersifra : [ ] ,
} ,
methods : {
managerZamenjajOznaci : function ( ) {
return this . managerOznaciVse = ! this . managerOznaciVse ;
} ,
emailObvestiloZaManagerje : function ( ) {
event . preventDefault ( ) ;
var polje = [ ] ;
$ ( '[name="manager"]:checked' ) . each ( function ( ) {
polje . push ( $ ( this ) . val ( ) ) ;
} ) ;
//Poljšemo podatke
$ . post ( "ajax.php?anketa=" + this . anketaId + "&t=hierarhija-ajax&a=ostalo&m=obvesti-managerje" , {
managerji : polje
} ) . then ( function ( response ) {
$ ( '[name="manager"]:checked' ) . each ( function ( ) {
$ ( this ) . hide ( ) ;
$ ( this ) . parent ( ) . prepend ( '<span> - </span>' ) ;
} ) ;
if ( response . data == 'success' ) {
swal ( {
title : "Obvestilo poslano!" ,
text : "Elektronsko sporočilo je bilo uspešno poslano." ,
type : "success" ,
timer : 3000
} ) ;
}
} ) ;
}
}
} ) ;
}
} ) ;
function izbrisiSifrant ( id ) {
var anketa _id = $ ( '#srv_meta_anketa_id' ) . val ( ) ;
$ . post ( "ajax.php?anketa=" + anketa _id + "&t=hierarhija-ajax&a=izbrisi_sifrant" , {
idSifranta : id
} ) . then ( function ( response ) {
if ( response == 1 )
return swal ( {
title : "Opozorilo!" ,
text : "Šifrant je že uporabljen in ga ni mogoče izbrisati." ,
type : "error" ,
timer : 3000
} ) ;
$ ( '[data-sifrant="' + id + '"]' ) . remove ( ) ;
} ) ;
}
// Pobriše vrstico iz DataTables in odstrani šifrante iz vseh nivojev pri izbiri
function pobrisiVrsticoHierarhije ( id ) {
gradnjaHierarhijeApp . $set ( 'izbran.sifrant' , [ ] ) ;
gradnjaHierarhijeApp . $set ( 'izbran.sifrantPodatki' , [ ] ) ;
// V kolikor gre za uporabnika na nižjem nivoju potem moramo ponovno pridobiti strukturo in vse podatke o fiksnih nivojih
gradnjaHierarhijeApp . preveriNivoInPraviceUporabnika ( ) ;
brisiVrsticoHierarhije ( id , 1 ) ;
}