当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript _.chain方法代码示例

本文整理汇总了TypeScript中entcore._.chain方法的典型用法代码示例。如果您正苦于以下问题:TypeScript _.chain方法的具体用法?TypeScript _.chain怎么用?TypeScript _.chain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在entcore._的用法示例。


在下文中一共展示了_.chain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: findCopyIndexOfCurrentCopy

            link:(scope:any) => {
                var subjectCopyList:ISubjectCopy[] =
                    _.chain(SubjectCopyService.getListBySubjectScheduled(scope.subjectScheduled)).filter(function (subjectCopy) {
                        //filter only copy has submitted or due_date is past
                        return SubjectCopyService.canCorrectACopyAsTeacher(scope.subjectScheduled, subjectCopy);
                    }).sortBy( function(subjectCopy) {
                    return subjectCopy.owner_username;
                }).value();
                
                scope.redirectToDashboard = function(isCorrected:boolean) {
                    if (isCorrected) {
                        var copy = SubjectCopyService.getById(scope.subjectCopy.id);
                        copy.is_correction_on_going = true;
                        copy.is_corrected = true;
                        scope.$emit('E_UPDATE_SUBJECT_COPY', copy, false);

                    } else {
                        $location.path('/dashboard/teacher/correction/'+scope.subjectScheduled.id);
                    }
                };

                scope.redirectToSubjectDashboard = function() {
                    $location.path('/dashboard');
                };

                scope.redirectToCorrectDashboard = function() {
                    $location.path('dashboard/teacher/correction');
                };

                scope.$on('E_SUBJECT_COPY_UPDATED', function(event, redirect:boolean) {
                    if (redirect) {
                        $location.path('/dashboard/teacher/correction/'+scope.subjectScheduled.id);
                    }
                });

                scope.copyIsCorrected = function(){
                    return scope.subjectCopy.is_corrected;
                };
                
                function findCopyIndexOfCurrentCopy() {
                    return _.findIndex(subjectCopyList, function(subjectCopy) { return subjectCopy.id === scope.subjectCopy.id });
                };

                scope.redirectToNextCopy = function() {
                    template.close("main");
                    let index = findCopyIndexOfCurrentCopy() + 1;
                    $timeout(function(){
                        $location.path('/subject/copy/view/'+ scope.subjectScheduled.subject_id + '/' +  subjectCopyList[index].id + '/');
                    },50);
                };

                scope.redirectToPreviousCopy = function() {
                    template.close("main");
                    let index = findCopyIndexOfCurrentCopy() - 1;
                     $timeout(function(){
                         $location.path('/subject/copy/view/'+ scope.subjectScheduled.subject_id + '/' +  subjectCopyList[index].id + '/');
                     },50);
                };

                scope.hasNextCopy = function() {
                    return scope.subjectCopy.id !== subjectCopyList[subjectCopyList.length-1].id;
                };

                scope.hasPreviousCopy = function() {
                    return scope.subjectCopy.id !== subjectCopyList[0].id;
                }
            }
开发者ID:OPEN-ENT-NG,项目名称:exercizer,代码行数:67,代码来源:subjectViewCopyTeacherHeader.ts


注:本文中的entcore._.chain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。