<commit_before><!DOCTYPE html>
<html ng-app="peoplePluginDesign">
<head lang="en">
    <meta charset="UTF-8">

    <!-- CSS -->
    <link href="../../../../styles/helper.css" rel="stylesheet">

    <!-- JS -->
    <script src="../../../../scripts/buildfire.js"></script>
    <script src="../../../../scripts/angular/angular.min.js"></script>
</head>
<body ng-controller="peoplePluginCtrl as peoplePlugin">

<div class="item row clearfix">
    <div class="labels col-md-3 padding-right-zero pull-left">
        <span>List Layout</span>
    </div>
    <div class="main col-md-9 pull-right">
        <div class="screens clearfix">
            <div class="screen layouticon pull-left">
                <a class="border-grey border-radius-three default-background-hover">{{peoplePlugin.selectedListLayout}}</a>
            </div>
            <div class="layoutgrid pull-right border-grey border-radius-three">
                <ul>
                    <li ng-repeat="layout in peoplePlugin.layouts">
                        <a class="layouticon border-grey border-radius-three default-background-hover"  ng-click="peoplePlugin.changeListLayout(layout)">{{layout.name}}</a>
                    </li>
                </ul>

                <!--<a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>-->
            </div>
        </div>
    </div>
</div>
<hr>
<div class="item row clearfix margin-top-thirty">
    <div class="labels col-md-3 padding-right-zero pull-left">
        <span>Item Layout</span>
    </div>
    <div class="main col-md-9 pull-right">
        <div class="screens clearfix">
            <div class="screen layouticon pull-left">
                <a class="border-grey border-radius-three default-background-hover">{{peoplePlugin.selectedItemLayout}}</a>
            </div>
            <div class="layoutgrid pull-right border-grey border-radius-three">
                <ul>
                    <li ng-repeat="layout in peoplePlugin.layouts">
                        <a class="layouticon border-grey border-radius-three default-background-hover" ng-click="peoplePlugin.changeItemLayout(layout)">{{layout.name}}</a>
                    </li>
                </ul>
                <!--<a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>-->
            </div>
        </div>
    </div>
</div>
<hr>
<div class="item row clearfix margin-top-thirty">
    <div class="labels col-md-3 padding-right-zero pull-left">
        <span>Item List Background Image</span>
    </div>
    <div class="main col-md-9 pull-right">
        <div class="screens clearfix">
            <div class="screen text-center layouticon pull-left">
                <a class="border-grey border-radius-three default-background-hover"></a>
                <label class="secondary">750x1334</label>
            </div>
        </div>
    </div>
</div>

<script>
    var peoplePluginApp = angular.module('peoplePluginDesign',[]);

    peoplePluginApp.controller('peoplePluginCtrl',['$scope',function($scope){
        var peoplePlugin=this;
        peoplePlugin.selectedItemLayout=null;
        peoplePlugin.selectedListLayout=null;


        var design = {
            listLayout:"",
            itemLayout:"",
            backgroundImage:""
        }

        buildfire.datastore.get('design',function(err,data){
            if(data && data.data)
            {
                if(data.data)
                {
                    design=data.data;
                    peoplePlugin.selectedItemLayout=data.data.itemLayout ? data.data.itemLayout: null;
                    peoplePlugin.selectedListLayout=data.data.listLayout ? data.data.listLayout: null;
                    $scope.$digest();
                    console.log(peoplePlugin.selectedItemLayout,peoplePlugin.selectedListLayout);
                }

                console.log("Data in get Design----------------------------------------------",data);
            }

        });
        peoplePlugin.layouts=[
            {name:'Layout1'},
            {name:'Layout2'},
            {name:'Layout3'},
            {name:'Layout4'},
            {name:'Layout5'},
            {name:'Layout6'},
            {name:'Layout7'},
            {name:'Layout8'},
            {name:'Layout9'},
            {name:'Layout10'}
        ];
        console.log('Layouts>>>>>>>>>>>>>>>>>',this.layouts);
        peoplePlugin.changeListLayout=function(layout){
            if(layout){

                //peoplePlugin.selectedItemLayout=null;
                buildfire.datastore.save(design,'design',function(err,data){
                    if(!err)
                    {
                        peoplePlugin.selectedListLayout=layout.name;
                        design.listLayout=layout.name;
                        $scope.$digest();
                    }
                    console.log('Error in save method>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>',err);
                    console.log('data in save method>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>',data);
                });
            }
        };
        peoplePlugin.changeItemLayout=function(layout){
            if(layout){
                // peoplePlugin.selectedListLayout=null;
                buildfire.datastore.save(design,'design',function(err,data){
                    if(!err){
                        peoplePlugin.selectedItemLayout=layout.name;
                        design.itemLayout=layout.name;
                        $scope.$digest();
                    }
                    console.log('Error in save method>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>',err);
                    console.log('data in save method>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>',data);
                });
            }
        };


    }]);
</script><commit_msg>PeoplePluginCtrl code refactored, Domain structure changed and Validation added on save data<commit_after><!DOCTYPE html>
<html ng-app="peoplePluginDesign">
<head lang="en">
    <meta charset="UTF-8">

    <!-- CSS -->
    <link href="../../../../styles/helper.css" rel="stylesheet">

    <!-- JS -->
    <script src="../../../../scripts/buildfire.js"></script>
    <script src="../../../../scripts/angular/angular.min.js"></script>
</head>
<body ng-controller="peoplePluginCtrl as PeoplePlugin">

<div class="item row clearfix">
    <div class="labels col-md-3 padding-right-zero pull-left">
        <span>List Layout</span>
    </div>
    <div class="main col-md-9 pull-right">
        <div class="screens clearfix">
            <div class="screen layouticon pull-left">
                <a class="border-grey border-radius-three default-background-hover">{{PeoplePlugin.peopleInfo.design.listLayout}}</a>
            </div>
            <div class="layoutgrid pull-right border-grey border-radius-three">
                <ul>
                    <li ng-repeat="layout in PeoplePlugin.layouts">
                        <a class="layouticon border-grey border-radius-three default-background-hover"
                           ng-click="PeoplePlugin.changeListLayout(layout.name)">{{layout.name}}</a>
                    </li>
                </ul>

                <!--<a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>-->
            </div>
        </div>
    </div>
</div>
<hr>
<div class="item row clearfix margin-top-thirty">
    <div class="labels col-md-3 padding-right-zero pull-left">
        <span>Item Layout</span>
    </div>
    <div class="main col-md-9 pull-right">
        <div class="screens clearfix">
            <div class="screen layouticon pull-left">
                <a class="border-grey border-radius-three default-background-hover">{{PeoplePlugin.peopleInfo.design.itemLayout}}</a>
            </div>
            <div class="layoutgrid pull-right border-grey border-radius-three">
                <ul>
                    <li ng-repeat="layout in PeoplePlugin.layouts">
                        <a class="layouticon border-grey border-radius-three default-background-hover"
                           ng-click="PeoplePlugin.changeItemLayout(layout.name)">{{layout.name}}</a>
                    </li>
                </ul>
                <!--<a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>
                <a class="layouticon border-grey border-radius-three default-background-hover"></a>-->
            </div>
        </div>
    </div>
</div>
<hr>
<div class="item row clearfix margin-top-thirty">
    <div class="labels col-md-3 padding-right-zero pull-left">
        <span>Item List Background Image</span>
    </div>
    <div class="main col-md-9 pull-right">
        <div class="screens clearfix">
            <div class="screen text-center layouticon pull-left">
                <a class="border-grey border-radius-three default-background-hover"></a>
                <label class="secondary">750x1334</label>
            </div>
        </div>
    </div>
</div>

<script>
    var peoplePluginApp = angular.module('peoplePluginDesign', []);

    peoplePluginApp.controller('peoplePluginCtrl', ['$scope', function ($scope) {
        var PeoplePlugin = this;
        var peoplePluginData;

        PeoplePlugin.changeListLayout = function (layoutName) {
            if (layoutName) {
                //PeoplePlugin.peopleInfo.design.$$hashKey="123445";
                PeoplePlugin.peopleInfo.design.listLayout = layoutName;
                saveData(function (err, data) {
                            if (err) {
                                PeoplePlugin.peopleInfo = angular.copy(peoplePluginData);
                            }
                            else {
                                if (data && data.obj) {
                                    peoplePluginData = data.obj;
                                }
                            }
                            $scope.$digest();
                        }
                )
                ;
            }
        };
        PeoplePlugin.changeItemLayout = function (layoutName) {
            if (layoutName) {
                PeoplePlugin.peopleInfo.design.itemLayout = layoutName;
                saveData(function (err, data) {
                    if (err) {
                        PeoplePlugin.peopleInfo = angular.copy(peoplePluginData);
                    }
                    else {
                        if (data && data.obj) {
                            peoplePluginData = data.obj;
                        }
                    }
                    $scope.$digest();
                });
            }
        };
        function saveData(callback) {
            callback = callback || function () {
            };
            buildfire.datastore.save(PeoplePlugin.peopleInfo, 'peopleInfo', callback);
        }

        function init() {
            PeoplePlugin.layouts = [
                {name: 'Layout1'},
                {name: 'Layout2'},
                {name: 'Layout3'},
                {name: 'Layout4'},
                {name: 'Layout5'},
                {name: 'Layout6'},
                {name: 'Layout7'},
                {name: 'Layout8'},
                {name: 'Layout9'},
                {name: 'Layout10'}
            ];
            PeoplePlugin.peopleInfo = {
                design: {
                    listLayout: "",
                    itemLayout: "",
                    backgroundImage: ""
                },
                content: {
                    images: [
                        {
                            imageUrl: "",
                            links: ""
                        }
                    ],
                    description: ""
                }
            };
            buildfire.datastore.get('peopleInfo', function (err, data) {
                if (err) {
                    return;
                }
                else {
                    if (data && data.data) {
                        PeoplePlugin.peopleInfo = angular.copy(data.data);
                        peoplePluginData = angular.copy(data.data);
                        $scope.$digest();
                    }
                }
            });
        }

        init();
    }])
    ;
</script>
{'fraction_non_alphanumeric': 0.1470568977934918, 'fraction_numerical': 0.0036666011916453873, 'mean_word_length': 1.681060207126558, 'pattern_counts': {'":': 0, '<': 233, '<?xml version=': 0, '>': 390, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1748002', 'n_tokens_mistral': 4054, 'n_tokens_neox': 3755, 'n_words': 705}