fcf.module({
  name: "fcfControls:templates/view.hooks.js",
  dependencies: [],
  module: function(){
    return {
      //
      // void hookBeforeBuild(a_taskInfo)
      // The hook is executed before assembling the template arguments
      //
      // hookBeforeBuild: function(a_taskInfo) {
      // },

      //
      // void hookAfterBuild(a_taskInfo)
      // The hook is executed after assembling the template arguments
      //
      // hookAfterBuild: function(a_taskInfo) {
      // },

      //
      // void hookAfterBuild(a_taskInfo)
      // The hook is executed after building the template's system arguments
      //
      // hookAfterSystemBuild: function(a_taskInfo) {
      // },

      //
      // Object of hooks for programmatically populated arguments
      //
      // hooksProgrammableArgument: {
      //   //
      //   // @result Returns the value of an argument or a Promise object
      //   //
      //   "ARG_NAME": function(a_taskInfo){
      //   }
      // },

      //
      // Object of the hooks preprocessing of the template arguments
      //
      // hooksBeforeArgument: {
      //   //
      //   // @result Can return the value of an argument or Promise or undefined
      //   //
      //   "ARG_NAME": function(a_taskInfo) {
      //   }
      // },

      //
      // Object of the hooks postprocessing of the template arguments
      hooksAfterArgument: {
        enable: (a_taskInfo)=>{
          let mode = typeof a_taskInfo.args.mode === "string" ? a_taskInfo.args.mode.split(".")[0] : "";
          if (mode == "edit" && a_taskInfo.args.notEdit){
            a_taskInfo.args.enable = false;
          } else if (mode == "add" && a_taskInfo.args.notAdd) {
            a_taskInfo.args.enable = false;
          }
        },
        value: async (a_taskInfo)=>{
          if ((a_taskInfo.args.mode == "add" || !a_taskInfo.args.mode)  && a_taskInfo.args.default !== undefined && a_taskInfo.args.value === undefined){
            await a_taskInfo.setValue("value", a_taskInfo.args.default);
          }
        }
      },
    };
  }
});
