/**
 * (c) by aheadware.com
 */

var app = app || {};
app.state = app.state || {};

app.state.GroupSetting = function()
{
    var state = app.core.StateManager.createState( 'group-setting' );

    state.onEnter = function( p )
    {
        var $content = app.core.View.getContent(),
            groupId = p.groupId;

        app.gui.PageLoader.show();

        app.core.Rpc.call(
            'Team',
            'getDetails',
            { teamId : groupId },
            function( res )
            {
                var mGroup = new app.model.Group(res.team),
                    currentProfile = null;

                app.core.View.setContent(
                    app.core.View.getTemplate(
                        'group-setting',
                        {
                            group: mGroup,
                            currentProfile: app.model.SessionUser.getUserProfile()
                        })
                );

                $content.find( '[data-id="btn-copy-ical-group-link"]' ).first().click( function()
                {
                    app.util.Helper.copyInputToClipboard( $content.find( '[data-id="input-group-ical"]' ).first() );
                    app.core.View.toastSuccess( _lc( 'CALENDER_LINK_COPIED' ) );
                });


                app.gui.PageLoader.hide();
            }
        );
    };

    return state;
};