$scope.ok = function()

in public/components/stub-modal/stub-modal.js [353:452]


    $scope.ok = function (addToComposer, addToAtomEditor) {
        const stub = setDisplayHintForFormat ($scope.stub);
        
        function createItemPromise() {
            if ($scope.contentName === 'Atom') {
                stub.contentType = $scope.stub.contentType.toLowerCase();
                if (addToAtomEditor) {
                    return wfContentService.createInAtomEditor(stub);
                } else if (stub.id) {
                    return wfContentService.updateStub(stub);
                } else {
                    return wfContentService.createStub(stub);
                }
            } else {
                if (addToComposer) {
                    return wfContentService.createInComposer(stub);
                } else if (stub.id) {
                    return wfContentService.updateStub(stub);
                } else {
                    return wfContentService.createStub(stub);
                }
            }
        }

        $scope.actionInProgress = true;

        createItemPromise().then(() => {
            const eventName = ({
                'create': {
                    category: 'Stub',
                    action: 'Created',
                    value: {
                      'Created in Composer': stub.composerId
                    }
                },
                'edit': {
                  category: 'Stub',
                  action: 'Edited'
                },
                'import': {
                  category: 'Content',
                  action: 'Imported'
                },
            }[$scope.mode]);

            $rootScope.$broadcast('track:event', eventName.category, eventName.action, null, null, Object.assign(
                {}, {
                    'Section': stub.section,
                    'Content type': stub.contentType
                }, eventName.value ? eventName.value : {})
            );

            $rootScope.$broadcast('getContent');

            if ($scope.contentName === 'Atom') {
                if (stub.editorId && ($scope.mode !== 'import')) {
                    $scope.editorUrl = wfContentService.getEditorUrl(stub.editorId, stub.contentType);
                } else {
                    $modalInstance.close({
                        addToEditor: addToAtomEditor,
                        stub: $scope.stub
                    });
                }
            } else {
                if(stub.composerId && ($scope.mode !== 'import')) {
                    $scope.composerUrl = config.composerViewContent + '/' + stub.composerId;
                } else {
                    $modalInstance.close({
                        addToComposer: addToComposer,
                        stub: $scope.stub
                    });
                }
            }

            $scope.actionSuccess = true;
            $scope.actionInProgress = false;
        }, (err) => {
            $scope.actionSuccess = false;
            $scope.contentUpdateError = true;

            if(err.status === 409) {
                if(err.data.composerId) {
                    $scope.composerUrl = config.composerViewContent + '/' + err.data.composerId;
                }
                if(err.data.editorId) {
                    $scope.editorUrl = wfContentService.getEditorUrl(stub.editorId, stub.contentType);
                }
                if(err.data.stubId) {
                    $scope.stubId = err.data.stubId;
                }
            } else {
                $scope.actionSuccess = false;
            }

            $rootScope.$apply(() => { throw new Error('Stub ' + mode + ' failed: ' + (err.message || err)); });

            $scope.actionInProgress = false;
        });

    };