• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

glorious-codes / glorious-pitsby-demo / 61661de0-c128-4dfd-91b2-2e820ab41a59

18 Nov 2023 09:40PM CUT coverage: 100.0%. Remained the same
61661de0-c128-4dfd-91b2-2e820ab41a59

push

circleci

rafaelcamargo
chore: update pitsby from 1.36.3 to 1.37.0

120 of 120 branches covered (100.0%)

Branch coverage included in aggregate %.

288 of 288 relevant lines covered (100.0%)

9.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/scripts/angular/components/form/form.js
1
import template from './form.html';
2

3
function controller($timeout, toaster){
4
  const $ctrl = this;
14✔
5

6
  $ctrl.handleSubmit = () => {
14✔
7
    setAlert(null);
13✔
8
    setProcessing(true);
13✔
9
    $ctrl.onSubmit().then(response => {
13✔
10
      $timeout(() => handleSubmitSuccess(response));
6✔
11
    }, err => {
12
      $timeout(() => handleSubmitError(err));
5✔
13
    });
14
  };
15

16
  function handleSubmitSuccess(response){
17
    setProcessing(false);
6✔
18
    popToast(buildSuccessToat($ctrl.successMessage));
6✔
19
    handleCustomCallback($ctrl.onSubmitSuccess, response);
6✔
20
  }
21

22
  function handleSubmitError(err){
23
    setProcessing(false);
4✔
24
    setAlert(buildErrorAlert($ctrl.errorMessage, $ctrl.handleSubmit));
4✔
25
    handleCustomCallback($ctrl.onSubmitError, err);
4✔
26
  }
27

28
  function setProcessing(processing){
29
    $ctrl.processing = processing;
23✔
30
  }
31

32
  function setAlert(alert){
33
    $ctrl.alert = alert;
17✔
34
  }
35

36
  function buildErrorAlert(message, onTriggerClick){
37
    return {
4✔
38
      theme: 'danger',
39
      message: message || 'Sorry, something went wrong.',
7✔
40
      onTriggerClick: onTriggerClick
41
    };
42
  }
43

44
  function buildSuccessToat(message){
45
    return {
6✔
46
      theme: 'success',
47
      message: message || 'Perfect! Request successfully processed.'
11✔
48
    };
49
  }
50

51
  function popToast(toast){
52
    toaster.pop(toast);
6✔
53
  }
54

55
  function handleCustomCallback(callback, data){
56
    if(callback)
10✔
57
      callback(data);
2✔
58
  }
59
}
60

61
controller.$inject = ['$timeout','toaster'];
34✔
62

63
export default {
64
  transclude: true,
65
  bindings: {
66
    onSubmit: '=',
67
    onSubmitSuccess: '=',
68
    onSubmitError: '=',
69
    successMessage: '@',
70
    errorMessage: '@'
71
  },
72
  controller,
73
  template
74
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc