How to use the farmbot.SpecialStatus.SAVING function in farmbot

To help you get started, we’ve selected a few farmbot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FarmBot / Farmbot-Web-App / webpack / resources / actions.ts View on Github external
export const generalizedError = (payload: GeneralizedError) => {
  const badStatus = payload.statusBeforeError == SpecialStatus.SAVING;
  if (badStatus) {
    /** If, somehow, a `SAVING` status sneaks in, default it to DIRTY. */
    payload.statusBeforeError = SpecialStatus.DIRTY;
  }
  toastErrors(payload);
  stopTracking(payload.uuid);
  return { type: Actions._RESOURCE_NO, payload };
};
github FarmBot / Farmbot-Web-App / webpack / resources / tagged_resources.ts View on Github external
export function getArrayStatus(i: TaggedResource[]): SpecialStatus {
  const r = betterCompact(_(i).map(x => x.specialStatus).uniq().value());
  if (r.length) {
    return (r.includes(SpecialStatus.SAVING)) ?
      SpecialStatus.SAVING : SpecialStatus.DIRTY;
  } else {
    return SpecialStatus.SAVED;
  }
}
github FarmBot / Farmbot-Web-App / frontend / ui / save_button.tsx View on Github external
export function SaveBtn(props: SaveBtnProps) {
  const STATUS_TRANSLATION: Partial> = {
    [SpecialStatus.DIRTY]: "is-dirty",
    [SpecialStatus.SAVING]: "is-saving"
  };

  const CAPTIONS: Partial> = {
    [SpecialStatus.DIRTY]: (props.dirtyText || t("Save") + " *"),
    [SpecialStatus.SAVING]: props.savingText || t("Saving")
  };

  const { savedText, onClick, hidden } = props;
  const statusClass = STATUS_TRANSLATION[props.status || ""] || "is-saved";
  const klass = `${props.color || "green"} ${statusClass} save-btn fb-button`;
  const spinnerEl = (props.status === SpecialStatus.SAVING) ?
    spinner : "";

  return <button hidden="{!!hidden}">
    {CAPTIONS[props.status] || (savedText || t("Saved") + " ✔")} {spinnerEl}
  </button>;
github FarmBot / Farmbot-Web-App / webpack / resources / reducer.ts View on Github external
.add(Actions.REFRESH_RESOURCE_START, (s, a) =&gt; {
      mutateSpecialStatus(a.payload, s.index, SpecialStatus.SAVING);
      return s;
    })
    .add(Actions.REFRESH_RESOURCE_NO, (s, { payload }) =&gt; {
github FarmBot / Farmbot-Web-App / frontend / account / components / change_password.tsx View on Github external
save = () => {
    const numUniqueValues = uniq(Object.values(this.state.form)).length;
    switch (numUniqueValues) {
      case 1:
        error(t("Provided new and old passwords match. Password not changed."),
          t("Error"));
        this.clearForm();
        break;
      case 2:
        if (confirm(t(Content.ACCOUNT_PASSWORD_CHANGE))) {
          this.setState({ status: SpecialStatus.SAVING });
          this.sendChange();
        }
        this.clearForm();
        break;
      case 3:
        error(t("New password and confirmation do not match."), t("Error"));
        this.clearForm();
        break;
      default:
        this.clearForm();
        throw new Error(trim(`Password change form error:
          ${numUniqueValues} unique values provided.`));
    }
  }
github FarmBot / Farmbot-Web-App / frontend / resources / tagged_resources.ts View on Github external
export function getArrayStatus(i: TaggedResource[]): SpecialStatus {
  const r = betterCompact(chain(i).map(x => x.specialStatus).uniq().value());
  if (r.length) {
    return (r.includes(SpecialStatus.SAVING)) ?
      SpecialStatus.SAVING : SpecialStatus.DIRTY;
  } else {
    return SpecialStatus.SAVED;
  }
}
github FarmBot / Farmbot-Web-App / webpack / ui / save_button.tsx View on Github external
export function SaveBtn(props: SaveBtnProps) {
  const STATUS_TRANSLATION: Partial&gt; = {
    [SpecialStatus.DIRTY]: "is-dirty",
    [SpecialStatus.SAVING]: "is-saving"
  };

  const CAPTIONS: Partial&gt; = {
    [SpecialStatus.DIRTY]: (props.dirtyText || t("Save") + " *"),
    [SpecialStatus.SAVING]: props.savingText || t("Saving")
  };

  const { savedText, onClick, hidden } = props;
  const statusClass = STATUS_TRANSLATION[props.status || ""] || "is-saved";
  const klass = `${props.color || "green"} ${statusClass} save-btn fb-button`;
  const spinnerEl = (props.status === SpecialStatus.SAVING) ?
    spinner : "";

  return <button hidden="{!!hidden}">
    {CAPTIONS[props.status] || (savedText || t("Saved") + " ✔")} {spinnerEl}
  </button>;
github FarmBot / Farmbot-Web-App / webpack / resources / tagged_resources.ts View on Github external
export function getArrayStatus(i: TaggedResource[]): SpecialStatus {
  const r = betterCompact(_(i).map(x => x.specialStatus).uniq().value());
  if (r.length) {
    return (r.includes(SpecialStatus.SAVING)) ?
      SpecialStatus.SAVING : SpecialStatus.DIRTY;
  } else {
    return SpecialStatus.SAVED;
  }
}
github FarmBot / Farmbot-Web-App / frontend / resources / actions.ts View on Github external
export const generalizedError = (payload: GeneralizedError) => {
  const badStatus = payload.statusBeforeError == SpecialStatus.SAVING;
  if (badStatus) {
    /** If, somehow, a `SAVING` status sneaks in, default it to DIRTY. */
    payload.statusBeforeError = SpecialStatus.DIRTY;
  }
  toastErrors(payload);
  stopTracking(payload.uuid);
  return { type: Actions._RESOURCE_NO, payload };
};
github FarmBot / Farmbot-Web-App / webpack / resources / reducer.ts View on Github external
.add(Actions.SAVE_RESOURCE_START, (s, { payload }) =&gt; {
      mutateSpecialStatus(payload.uuid, s.index, SpecialStatus.SAVING);
      return s;
    })
    .add(Actions.BATCH_INIT, (s, { payload }) =&gt; {